import {z} from 'zod' export type PatchApiBankingEntitiesEntityIdOnboardingsOnboardingIdArgs = {entity_id: string, onboarding_id: string, body: {account_id: string, compliance_declaration?: ({terms_of_service?: ({accepted?: boolean | undefined, version?: string | undefined, accepted_at?: string | undefined, accepted_ip?: string | undefined}) | undefined, privacy_policy?: ({accepted?: boolean | undefined, version?: string | undefined, accepted_at?: string | undefined, accepted_ip?: string | undefined}) | undefined}) | undefined, risk_assessment?: ({assessed_at?: string | undefined, pep_status?: ({is_pep?: boolean | undefined, pep_level?: (string | null) | undefined, position?: (string | null) | undefined, country?: (string | null) | undefined}) | undefined, rca_status?: ({risk_level?: ('LOW' | 'MEDIUM' | 'HIGH') | undefined, classified_at?: string | undefined, assessed_by?: string | undefined}) | undefined, sanctions_screening?: ({appears_on_sanctions_list?: boolean | undefined, sanctions_list_name?: (string | null) | undefined, screened_at?: string | undefined}) | undefined}) | undefined, source_of_funds?: ({primary_source?: ('EMPLOYMENT_SALARY' | 'BUSINESS_INCOME' | 'INVESTMENTS' | 'RENTAL_INCOME' | 'PENSION' | 'GOVERNMENT_BENEFITS' | 'INHERITANCE' | 'FAMILY_SUPPORT' | 'SAVINGS' | 'LOTTERY_GAMBLING' | 'SALE_OF_ASSETS' | 'CRYPTOCURRENCY' | 'FREELANCE_CONSULTING' | 'OTHER') | undefined, secondary_sources?: Array | undefined, description?: string | undefined, estimated_annual_income?: ({amount?: number | undefined, currency?: string | undefined}) | undefined}) | undefined, documentation?: (Array<{type: 'IDENTITY_DOCUMENT' | 'PROOF_OF_ADDRESS' | 'BANK_STATEMENT' | 'BUSINESS_DOCUMENT' | 'TAX_INFORMATION' | 'FINANCIAL_DOCUMENT' | 'BIOMETRIC_VERIFICATION' | 'EMPLOYMENT_INFORMATION'}>) | undefined}}; export type PatchApiBankingEntitiesEntityIdOnboardingsOnboardingIdOptions = {baseUrl?: string | undefined, publicApiKey?: string | undefined, privateSecretKey?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiBankingEntitiesEntityIdOnboardingsOnboardingIdResponse = z.object({id: z.string().optional(), entity_id: z.string().optional(), status: z.string().optional(), provider_status: z.string().optional(), requirements: z.array(z.object({})).optional(), updated_at: 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 Entity Onboarding (Banking Connectivity) * * PATCH /banking/entities/{entity_id}/onboardings/{onboarding_id} */ export const patchApiBankingEntitiesEntityIdOnboardingsOnboardingId = async (args: PatchApiBankingEntitiesEntityIdOnboardingsOnboardingIdArgs, options?: PatchApiBankingEntitiesEntityIdOnboardingsOnboardingIdOptions) => { const {baseUrl = "https://api-sandbox.y.uno/v1", fetch: fetchFn = fetch, publicApiKey, privateSecretKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (publicApiKey !== undefined) headers.set("PUBLIC-API-KEY", publicApiKey) if (privateSecretKey !== undefined) headers.set("PRIVATE-SECRET-KEY", privateSecretKey) const url = `${baseUrl.replace(/\/+$/, '')}/banking/entities/${encodeURIComponent(String(args.entity_id))}/onboardings/${encodeURIComponent(String(args.onboarding_id))}${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(patchApiBankingEntitiesEntityIdOnboardingsOnboardingIdResponse, await res.json()) };