import {z} from 'zod' export type CreateApiProxyServicesDictProxyClaimsIdCompleteArgs = {id: string}; export type CreateApiProxyServicesDictProxyClaimsIdCompleteOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const dictProxyClaimSchemeData = z.object({claim_id: z.string().nullable(), claimer_tax_identification_number: z.string(), claimer_owner_type: z.enum(["individual", "legal_entity"]), claimer_opening_date: z.string().nullable(), confirm_reason: z.enum(["USER_REQUESTED", "ACCOUNT_CLOSURE", "DEFAULT_OPERATION", "null"]).nullable(), cancel_reason: z.string().nullable(), cancelled_by: z.string().nullable(), last_modified: z.string().nullable()}); export const dictProxyClaim = z.object({id: z.string(), object: z.literal("proxy_claim"), scheme: z.string(), type: z.enum(["ownership", "portability"]), role: z.enum(["claimer", "donor"]), status: z.enum(["pending_creation", "open", "creation_rejected", "pending_acknowledgment", "waiting_resolution", "acknowledgment_rejected", "pending_confirmation", "confirmed", "confirmation_rejected", "pending_cancellation", "cancelled", "cancellation_rejected", "pending_completion", "completed", "completion_rejected"]), status_details: z.string().nullable(), proxy_type: z.enum(["phone", "email", "tax_id", "organisation", "random_alias"]), proxy_type_code: z.string().nullable(), proxy_identification: z.string(), claimer_name: z.string(), claimer_account_identification: z.string(), claimer_account_type: z.enum(["CACC", "SVGS", "SLRY", "TRAN", "null"]).nullable(), claimer_account_issuer: z.string().nullable(), claimer_servicer: z.string(), donor_servicer: z.string().nullable(), connected_account_id: z.string(), internal_account_id: z.string().nullable(), proxy_key_id: z.string().nullable(), resolution_period_end: z.string().nullable(), completion_period_end: z.string().nullable(), scheme_data: dictProxyClaimSchemeData, metadata: z.record(z.string(), z.unknown()), created_at: z.string(), updated_at: z.string().nullable()}); 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 }; /** * Complete DICT proxy claim * * POST /proxy_services/dict/proxy_claims/{id}/complete */ export const createApiProxyServicesDictProxyClaimsIdComplete = async (args: CreateApiProxyServicesDictProxyClaimsIdCompleteArgs, options?: CreateApiProxyServicesDictProxyClaimsIdCompleteOptions) => { const {baseUrl = "https://sandbox.numeral.io/v1", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("x-api-key", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/proxy_services/dict/proxy_claims/${encodeURIComponent(String(args.id))}/complete${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(dictProxyClaim, await res.json()) };