import {z} from 'zod' export type Address = {address_street_1?: string | undefined, address_street_2?: string | undefined, address_city?: string | undefined, address_state?: string | undefined, address_zip_code?: string | undefined, address_country?: string | undefined}; export type BusinessAdditionalInfoType = 'BANK_STATEMENT_DOCUMENT' | 'BUSINESS_REGISTRATION_DOCUMENT' | 'OPERATING_LICENSE_DOCUMENT' | 'FRAUD_CHECK_DOCUMENT' | 'ADDRESS_PROOF_DOCUMENT' | 'BANK_ACCOUNT_DETAILS' | 'SOURCE_OF_FUNDS_DOCUMENT' | 'CHAMBER_OF_COMMERCE_CERTIFICATE' | 'CAC_CERTIFICATE' | 'ARTICLES_OF_INCORPORATION' | 'AML_POLICY' | 'FINANCIAL_CONDUCT_AUTHORITY_AUTHORIZATION' | 'DIRECTORS_REGISTRY' | 'CORPORATE_CHART' | 'SHAREHOLDERS_REGISTRY' | 'BALANCE_SHEET' | 'REPORTING_ENTITY_REGISTRATION_DOCUMENT' | 'COMPANY_CONSTITUTION' | 'MEMORANDUM_OF_ASSOCIATION' | 'PARTNERSHIP_DEED' | 'CERTIFIED_ANNUAL_RETURNS_STATEMENT' | 'COMPANY_PROFILE' | 'AUDITED_ACCOUNTS' | 'ANTI_BRIBERY_POLICY' | 'DATA_PROTECTION_POLICY' | 'INVOICE' | 'PEP_FORM' | 'TAX_REGISTRATION_CERTIFICATE' | 'INTENDED_USAGE_DOCUMENT' | 'OTHER'; export type CreateBusinessProfileAdditionalInfoItem = {additional_info_type?: BusinessAdditionalInfoType | undefined, additional_info_data?: (string | {file_data: string}) | undefined}; export type CreateBusinessProfileAdditionalInformation = Array; export type UpdateBusinessProfileRequestSchema = {business_profile_id: string, name?: string | undefined, alternate_name?: string | undefined, tax_identification_number?: string | undefined, website?: string | undefined, formation_date?: string | undefined, country_code?: string | undefined, state_code?: string | undefined, business_entity_id?: string | undefined, addresses?: Array
| undefined, phone_numbers?: Array | undefined, email_addresses?: Array | undefined, additional_information?: CreateBusinessProfileAdditionalInformation | undefined, client_reference_id?: string | undefined, client_reference_data?: Record | undefined, callback_url?: string | undefined, events_callback_url?: string | undefined, tags?: Array | undefined}; export type CreateApiVerifyUpdateBusinessProfileArgs = {body: UpdateBusinessProfileRequestSchema}; export type CreateApiVerifyUpdateBusinessProfileOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiVerifyUpdateBusinessProfileResponse = z.object({business_profile_id: 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 }; /** * Update Business Profile * * POST /verify/update_business_profile */ export const createApiVerifyUpdateBusinessProfile = async (args: CreateApiVerifyUpdateBusinessProfileArgs, options?: CreateApiVerifyUpdateBusinessProfileOptions) => { const {baseUrl = "https://api-sandbox.aiprise.com/api/v1", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (apiKey !== undefined) headers.set("X-API-KEY", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/verify/update_business_profile${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(createApiVerifyUpdateBusinessProfileResponse, await res.json()) };