Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new KYC schema #121

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/kyc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ export const kycStatusSchema = z.nativeEnum(KycStatus, {
// When adding new schemas be sure to also update kycSchemasSchema
export enum KycSchema {
PersonalDataAndDocuments = 'PersonalDataAndDocuments',
PersonalDataAndDocumentsDetailed = 'PersonalDataAndDocumentsDetailed',
}
export const kycSchemaSchema = z.nativeEnum(KycSchema, {
description: 'kycSchemaSchema',
})

export enum KycDocumentType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the naming convention used in the specification itself; this should be IdentificationDocumentType.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, changed.

IDC = 'IDC',
PAS = 'PAS',
DL = 'DL',
}
export const kycDocumentTypeSchema = z.nativeEnum(KycDocumentType, {
description: 'kycDocumentTypeSchema',
})

export const personalDataAndDocumentsKycSchema = z.object(
{
firstName: z.string(),
Expand Down Expand Up @@ -56,10 +66,40 @@ export type PersonalDataAndDocumentsKyc = z.infer<
typeof personalDataAndDocumentsKycSchema
>

export const personalDataAndDocumentsDetailedKycSchema = z.object({
firstName: z.string(),
middleName: z.string().optional(),
lastName: z.string(),
dateOfBirth: z.object({
day: z.string(),
month: z.string(),
year: z.string(),
}),
address: z.object({
address1: z.string(),
address2: z.string().optional(),
isoCountryCode: z.string(),
isoRegionCode: z.string(),
city: z.string(),
postalCode: z.string().optional(),
}),
phoneNumber: z.string(),
email: z.string(),
selfieDocument: z.string(),
identificationDocumentType: z.enum(['IDC', 'PAS', 'DL']),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reference the type created above rather than repeating the hardcoded string values here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Changed

identificationDocumentFront: z.string(),
identificationDocumentBack: z.string().optional(),
})
export type PersonalDataAndDocumentsDetailedKyc = z.infer<
typeof personalDataAndDocumentsDetailedKycSchema
>

export const kycSchemasSchema = z.object(
{
[kycSchemaSchema.enum.PersonalDataAndDocuments]:
personalDataAndDocumentsKycSchema,
[kycSchemaSchema.enum.PersonalDataAndDocumentsDetailed]:
personalDataAndDocumentsDetailedKycSchema,
},
{ description: 'kycSchemasSchema' },
)
Expand Down