import {z} from 'zod' export type LocationCoords = {accuracy?: number | undefined, lat?: number | undefined, lon?: number | undefined}; export type LocationPosition = {formattedAddress?: string | undefined, locationCoords?: LocationCoords | undefined, skipped?: boolean | undefined}; export type AddressSource = 'manual' | 'autoComplete' | 'gps' | 'externalDb' | 'proofOfAddress' | 'proofOfIdentity'; export type Address = {buildingName?: string | undefined, buildingNumber?: string | undefined, country?: string | undefined, endDate?: string | undefined, flatNumber?: string | undefined, formattedAddress?: string | undefined, locationPosition?: LocationPosition | undefined, postCode?: string | undefined, providedLocationPosition?: LocationPosition | undefined, source?: AddressSource | undefined, startDate?: string | undefined, state?: string | undefined, stateCode?: string | undefined, stateEn?: string | undefined, street?: string | undefined, streetEn?: string | undefined, subStreet?: string | undefined, subStreetEn?: string | undefined, town?: string | undefined, townEn?: string | undefined}; export type CompanyLegalForm = string; export type ApplicantMetadataKV = {key?: string | undefined, value?: string | undefined}; export type CompanyBeneficiaryInfo = {alternativeNames?: Array | undefined, buildingNumber?: string | undefined, companyName?: string | undefined, controlScheme?: string | undefined, country?: string | undefined, countryOfBirth?: string | undefined, dob?: string | undefined, email?: string | undefined, externalUserId?: string | undefined, firstName?: string | undefined, flatNumber?: string | undefined, gender?: string | undefined, incorporatedOn?: string | undefined, lastName?: string | undefined, legalAddress?: string | undefined, legalForm?: CompanyLegalForm | undefined, legalName?: string | undefined, leiCode?: string | undefined, metadata?: Array | undefined, middleName?: string | undefined, nationality?: string | undefined, phone?: string | undefined, placeOfBirth?: string | undefined, postCode?: string | undefined, postalAddress?: string | undefined, registrationLocation?: string | undefined, registrationNumber?: string | undefined, shareSize?: number | undefined, state?: string | undefined, stateOfBirth?: string | undefined, street?: string | undefined, subStreet?: string | undefined, taxId?: string | undefined, taxResidenceCountry?: string | undefined, tin?: string | undefined, town?: string | undefined, type?: string | undefined, website?: string | undefined}; export type CompanyBeneficiarySubtype = 'ownershipUbo' | 'controlUbo' | 'substituteUbo'; export type CompanyBeneficiaryType = 'shareholder' | 'representative' | 'director' | 'ubo' | 'companyOfficer' | 'secretary' | 'founder' | 'investor' | 'legalAdvisor' | 'authorizedSignatory' | 'trustee' | 'trustBeneficiary' | 'trustSettlor' | 'trustProtector' | 'managingPartner' | 'equityPartner' | 'fundInvestor' | 'fundManager' | 'investmentManager' | 'investmentAdviser' | 'fundAdministrator' | 'depositary' | 'custodian' | 'primeBroker' | 'accountUser' | 'payer'; export type CompanyBeneficiary = {applicantId?: string | undefined, appointedOn?: string | undefined, beneficiaryInfo?: CompanyBeneficiaryInfo | undefined, id?: string | undefined, imageIds?: Array | undefined, inRegistry?: boolean | undefined, matched?: boolean | undefined, natureOfControl?: string | undefined, positions?: Array | undefined, resignedOn?: string | undefined, shareSize?: number | undefined, submitted?: boolean | undefined, subtypes?: Array | undefined, type?: CompanyBeneficiaryType | undefined, types?: Array | undefined}; export type CompanyAddressType = 'trade' | 'legal' | 'postal'; export type CompanyAddress = {address: Address, addressTypes?: Array | undefined, id?: string | undefined, imageId?: number | undefined, main?: boolean | undefined}; export type ApplicantCompanyInfoCustomInfoItem = {key?: string | undefined, value?: string | undefined}; export type IdDocSubType = 'FRONT_SIDE' | 'BACK_SIDE' | 'PAGES' | 'INCORPORATION_CERT' | 'INCORPORATION_ARTICLES' | 'ARTICLES_OF_ASSOCIATION' | 'PARTNERSHIP_AGREEMENT' | 'REGULATORY_LICENSE' | 'TRADE_LICENSE' | 'SHAREHOLDER_REGISTRY' | 'DIRECTORS_REGISTRY' | 'STATE_REGISTRY' | 'OWNERSHIP_STRUCTURE_CHART' | 'INCUMBENCY_CERT' | 'PROOF_OF_ADDRESS' | 'TAX_CERT' | 'PROOF_OF_NATURE_OF_BUSINESS' | 'SELF_DECLARATION_FORM' | 'POWER_OF_ATTORNEY' | 'MEMORANDUM_OF_ASSOCIATION' | 'OPERATING_AGREEMENT' | 'BYLAWS' | 'CHARTER' | 'BOARD_RESOLUTION' | 'CERTIFICATE_OF_STATUS' | 'CERTIFICATE_OF_REGISTRATION_CONTINUATION' | 'PROOF_OF_DOMAIN' | 'TRUST_AGREEMENT' | 'INFORMATION_STATEMENT' | 'GOOD_STANDING_CERT' | 'OTHER'; export type IdDocType = 'ID_CARD' | 'PASSPORT' | 'TRAVEL_PASSPORT' | 'DRIVERS' | 'SNILS' | 'RESIDENCE_PERMIT' | 'WORK_PERMIT' | 'WORK_PATENT' | 'VISA' | 'EMPLOYMENT_CERTIFICATE' | 'DRIVERS_TRANSLATION' | 'PASSPORT_TRANSLATION' | 'UTILITY_BILL' | 'UTILITY_BILL2' | 'ID_AS_POA' | 'SELFIE' | 'VIDEO_SELFIE' | 'PAYMENT_SELFIE' | 'STUDENT_ID' | 'BANK_CARD' | 'PROOF_OF_PAYMENT' | 'BANK_STATEMENT' | 'PROFILE_IMAGE' | 'PROFILE_SCREENSHOT' | 'ID_DOC_PHOTO' | 'MRZ_DOCUMENT' | 'AGREEMENT' | 'OTHER' | 'OTHER2' | 'OTHER3' | 'CONTRACT' | 'SIGNED_CONTRACT' | 'INVESTOR_DOC' | 'COMPANY_DOC' | 'VAT_CERTIFICATE' | 'POWER_OF_ATTORNEY' | 'TRANSPARENCY_REGISTRY_EXTRACT' | 'INCOME_SOURCE' | 'VEHICLE_REGISTRATION_CERTIFICATE' | 'VEHICLE_PASSPORT' | 'LEGAL_ENTITY' | 'MIGRATION_CARD' | 'ARRIVAL_NOTICE' | 'PAYMENT_METHOD' | 'PAYMENT_SOURCE' | 'INSURANCE_CERTIFICATE' | 'TAXI_LICENSE' | 'COVID_VACCINATION_FORM' | 'COVID_TEST_FORM' | 'TAX_PAYER_NUMBER_DOC' | 'FILE_ATTACHMENT' | 'ARBITRARY_DOC' | 'VOTER_ID' | 'IDENTITY_VIDEO' | 'EXTERNAL_DB_DOC' | 'DEBUG'; export type CompanyDocumentExpirationInfo = {expirationDate?: string | undefined, idDocSubType?: IdDocSubType | undefined, idDocType?: IdDocType | undefined, imageId?: number | undefined}; export type ApplicantCompanyInfo = {address?: Address | undefined, alternativeNames?: Array | undefined, applicantPosition?: string | undefined, beneficiaries?: Array | undefined, companyAddresses?: Array | undefined, companyName?: string | undefined, companyNameEn?: string | undefined, controlScheme?: string | undefined, country?: string | undefined, customInfo?: Array | undefined, email?: string | undefined, incorporatedOn?: string | undefined, legalAddress?: string | undefined, legalForm?: CompanyLegalForm | undefined, leiCode?: string | undefined, licenseNumber?: string | undefined, noDirectors?: boolean | undefined, noDocs?: boolean | undefined, noRepresentatives?: boolean | undefined, noShareholders?: boolean | undefined, noUBOs?: boolean | undefined, ownershipStructureDepth?: number | undefined, phone?: string | undefined, postalAddress?: string | undefined, primaryContactBeneficiaryId?: string | undefined, registrationLocation?: string | undefined, registrationNumber?: string | undefined, skippedTypes?: Array | undefined, taxId?: string | undefined, type?: string | undefined, upcomingDocumentExpiration?: CompanyDocumentExpirationInfo | undefined, website?: string | undefined}; export type PatchApiResourcesApplicantsApplicantIdInfoCompanyInfoArgs = {applicantId: string, unsetFields?: string | undefined, body: ApplicantCompanyInfo}; export type PatchApiResourcesApplicantsApplicantIdInfoCompanyInfoOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const locationCoords = z.object({accuracy: z.number().optional(), lat: z.number().optional(), lon: z.number().optional()}); export const locationPosition = z.object({formattedAddress: z.string().optional(), locationCoords: locationCoords.optional(), skipped: z.boolean().optional()}); export const addressSource = z.enum(["manual", "autoComplete", "gps", "externalDb", "proofOfAddress", "proofOfIdentity"]); export const address = z.object({buildingName: z.string().optional(), buildingNumber: z.string().optional(), country: z.string().optional(), endDate: z.string().optional(), flatNumber: z.string().optional(), formattedAddress: z.string().optional(), locationPosition: locationPosition.optional(), postCode: z.string().optional(), providedLocationPosition: locationPosition.optional(), source: addressSource.optional(), startDate: z.string().optional(), state: z.string().optional(), stateCode: z.string().optional(), stateEn: z.string().optional(), street: z.string().optional(), streetEn: z.string().optional(), subStreet: z.string().optional(), subStreetEn: z.string().optional(), town: z.string().optional(), townEn: z.string().optional()}); export const companyLegalForm = z.string(); export const applicantMetadataKV = z.object({key: z.string().optional(), value: z.string().optional()}); export const companyBeneficiaryInfo = z.object({alternativeNames: z.array(z.string()).optional(), buildingNumber: z.string().optional(), companyName: z.string().optional(), controlScheme: z.string().optional(), country: z.string().optional(), countryOfBirth: z.string().optional(), dob: z.string().optional(), email: z.string().optional(), externalUserId: z.string().max(512).optional(), firstName: z.string().optional(), flatNumber: z.string().optional(), gender: z.string().optional(), incorporatedOn: z.string().optional(), lastName: z.string().optional(), legalAddress: z.string().optional(), legalForm: companyLegalForm.optional(), legalName: z.string().optional(), leiCode: z.string().optional(), metadata: z.array(applicantMetadataKV).optional(), middleName: z.string().optional(), nationality: z.string().optional(), phone: z.string().optional(), placeOfBirth: z.string().optional(), postCode: z.string().optional(), postalAddress: z.string().optional(), registrationLocation: z.string().optional(), registrationNumber: z.string().optional(), shareSize: z.number().optional(), state: z.string().optional(), stateOfBirth: z.string().optional(), street: z.string().optional(), subStreet: z.string().optional(), taxId: z.string().optional(), taxResidenceCountry: z.string().optional(), tin: z.string().optional(), town: z.string().optional(), type: z.string().optional(), website: z.string().optional()}); export const companyBeneficiarySubtype = z.enum(["ownershipUbo", "controlUbo", "substituteUbo"]); export const companyBeneficiaryType = z.enum(["shareholder", "representative", "director", "ubo", "companyOfficer", "secretary", "founder", "investor", "legalAdvisor", "authorizedSignatory", "trustee", "trustBeneficiary", "trustSettlor", "trustProtector", "managingPartner", "equityPartner", "fundInvestor", "fundManager", "investmentManager", "investmentAdviser", "fundAdministrator", "depositary", "custodian", "primeBroker", "accountUser", "payer"]); export const companyBeneficiary = z.object({applicantId: z.string().optional(), appointedOn: z.string().optional(), beneficiaryInfo: companyBeneficiaryInfo.optional(), id: z.string().optional(), imageIds: z.array(z.string()).optional(), inRegistry: z.boolean().optional(), matched: z.boolean().optional(), natureOfControl: z.string().max(255).optional(), positions: z.array(z.string()).optional(), resignedOn: z.string().optional(), shareSize: z.number().optional(), submitted: z.boolean().optional(), subtypes: z.array(companyBeneficiarySubtype).optional(), type: companyBeneficiaryType.optional(), types: z.array(companyBeneficiaryType).optional()}); export const companyAddressType = z.enum(["trade", "legal", "postal"]); export const companyAddress = z.object({address: address, addressTypes: z.array(companyAddressType).optional(), id: z.string().max(256).optional(), imageId: z.number().int().optional(), main: z.boolean().optional()}); export const applicantCompanyInfoCustomInfoItem = z.object({key: z.string().max(255).optional(), value: z.string().max(255).optional()}); export const idDocSubType = z.enum(["FRONT_SIDE", "BACK_SIDE", "PAGES", "INCORPORATION_CERT", "INCORPORATION_ARTICLES", "ARTICLES_OF_ASSOCIATION", "PARTNERSHIP_AGREEMENT", "REGULATORY_LICENSE", "TRADE_LICENSE", "SHAREHOLDER_REGISTRY", "DIRECTORS_REGISTRY", "STATE_REGISTRY", "OWNERSHIP_STRUCTURE_CHART", "INCUMBENCY_CERT", "PROOF_OF_ADDRESS", "TAX_CERT", "PROOF_OF_NATURE_OF_BUSINESS", "SELF_DECLARATION_FORM", "POWER_OF_ATTORNEY", "MEMORANDUM_OF_ASSOCIATION", "OPERATING_AGREEMENT", "BYLAWS", "CHARTER", "BOARD_RESOLUTION", "CERTIFICATE_OF_STATUS", "CERTIFICATE_OF_REGISTRATION_CONTINUATION", "PROOF_OF_DOMAIN", "TRUST_AGREEMENT", "INFORMATION_STATEMENT", "GOOD_STANDING_CERT", "OTHER"]); export const idDocType = z.enum(["ID_CARD", "PASSPORT", "TRAVEL_PASSPORT", "DRIVERS", "SNILS", "RESIDENCE_PERMIT", "WORK_PERMIT", "WORK_PATENT", "VISA", "EMPLOYMENT_CERTIFICATE", "DRIVERS_TRANSLATION", "PASSPORT_TRANSLATION", "UTILITY_BILL", "UTILITY_BILL2", "ID_AS_POA", "SELFIE", "VIDEO_SELFIE", "PAYMENT_SELFIE", "STUDENT_ID", "BANK_CARD", "PROOF_OF_PAYMENT", "BANK_STATEMENT", "PROFILE_IMAGE", "PROFILE_SCREENSHOT", "ID_DOC_PHOTO", "MRZ_DOCUMENT", "AGREEMENT", "OTHER", "OTHER2", "OTHER3", "CONTRACT", "SIGNED_CONTRACT", "INVESTOR_DOC", "COMPANY_DOC", "VAT_CERTIFICATE", "POWER_OF_ATTORNEY", "TRANSPARENCY_REGISTRY_EXTRACT", "INCOME_SOURCE", "VEHICLE_REGISTRATION_CERTIFICATE", "VEHICLE_PASSPORT", "LEGAL_ENTITY", "MIGRATION_CARD", "ARRIVAL_NOTICE", "PAYMENT_METHOD", "PAYMENT_SOURCE", "INSURANCE_CERTIFICATE", "TAXI_LICENSE", "COVID_VACCINATION_FORM", "COVID_TEST_FORM", "TAX_PAYER_NUMBER_DOC", "FILE_ATTACHMENT", "ARBITRARY_DOC", "VOTER_ID", "IDENTITY_VIDEO", "EXTERNAL_DB_DOC", "DEBUG"]); export const companyDocumentExpirationInfo = z.object({expirationDate: z.string().optional(), idDocSubType: idDocSubType.optional(), idDocType: idDocType.optional(), imageId: z.number().int().optional()}); export const applicantCompanyInfo = z.object({address: address.optional(), alternativeNames: z.array(z.string()).optional(), applicantPosition: z.string().optional(), beneficiaries: z.array(companyBeneficiary).optional(), companyAddresses: z.array(companyAddress).optional(), companyName: z.string().optional(), companyNameEn: z.string().max(255).optional(), controlScheme: z.string().optional(), country: z.string().optional(), customInfo: z.array(applicantCompanyInfoCustomInfoItem).optional(), email: z.string().optional(), incorporatedOn: z.string().optional(), legalAddress: z.string().optional(), legalForm: companyLegalForm.optional(), leiCode: z.string().optional(), licenseNumber: z.string().max(64).optional(), noDirectors: z.boolean().optional(), noDocs: z.boolean().optional(), noRepresentatives: z.boolean().optional(), noShareholders: z.boolean().optional(), noUBOs: z.boolean().optional(), ownershipStructureDepth: z.number().int().optional(), phone: z.string().optional(), postalAddress: z.string().optional(), primaryContactBeneficiaryId: z.string().max(64).optional(), registrationLocation: z.string().optional(), registrationNumber: z.string().optional(), skippedTypes: z.array(companyBeneficiaryType).optional(), taxId: z.string().optional(), type: z.string().optional(), upcomingDocumentExpiration: companyDocumentExpirationInfo.optional(), website: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * PATCH /resources/applicants/{applicantId}/info/companyInfo */ export const patchApiResourcesApplicantsApplicantIdInfoCompanyInfo = async (args: PatchApiResourcesApplicantsApplicantIdInfoCompanyInfoArgs, options: PatchApiResourcesApplicantsApplicantIdInfoCompanyInfoOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json;charset=UTF-8") headers.set('accept', "application/json;charset=UTF-8") if (args.unsetFields != null) query.append("unsetFields", String(args.unsetFields)) const url = `${baseUrl.replace(/\/+$/, '')}/resources/applicants/${encodeURIComponent(String(args.applicantId))}/info/companyInfo${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(applicantCompanyInfo, await res.json()) };