import {z} from 'zod' export type GetApiProxyServicesDictProxyLookupsArgs = {limit?: number | undefined, starting_after?: string | undefined, status?: ('created' | 'processing' | 'sent' | 'completed' | 'rejected') | undefined, connected_account_id?: string | undefined, proxy_type?: ('phone' | 'email' | 'tax_id' | 'organisation' | 'random_alias') | undefined, proxy_type_code?: ('cpf' | 'cnpj' | 'abn' | 'teli' | 'emal' | 'aubn' | 'orgn' | 'evp') | undefined}; export type GetApiProxyServicesDictProxyLookupsOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const dictProxyLookupSchemeData = z.object({pi_payer_id: z.string(), pi_end_to_end_id: z.string(), pi_requesting_participant: z.string(), owner_statistics: z.record(z.string(), z.unknown()), key_statistics: z.record(z.string(), z.unknown())}); export const dictProxyLookup = z.object({id: z.string(), object: z.literal("proxy_lookup"), scheme: z.string(), status: z.enum(["created", "processing", "sent", "completed", "rejected"]), status_reason: z.string().nullable(), 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(), owner_name: z.string().nullable(), owner_type: z.enum(["individual", "legal_entity", "null"]).nullable().optional(), account_identification: z.string().nullable(), account_type: z.string().nullable(), account_issuer: z.string().nullable(), servicer: z.string().nullable(), connected_account_id: z.string(), scheme_data: dictProxyLookupSchemeData, created_at: z.string(), updated_at: z.string().nullable()}); export const dictProxyLookupListResult = z.object({records: z.array(dictProxyLookup)}); 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 }; /** * List DICT proxy lookups * * GET /proxy_services/dict/proxy_lookups */ export const getApiProxyServicesDictProxyLookups = async (args: GetApiProxyServicesDictProxyLookupsArgs, options?: GetApiProxyServicesDictProxyLookupsOptions) => { 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 (args.limit != null) query.append("limit", String(args.limit)) if (args.starting_after != null) query.append("starting_after", String(args.starting_after)) if (args.status != null) query.append("status", String(args.status)) if (args.connected_account_id != null) query.append("connected_account_id", String(args.connected_account_id)) if (args.proxy_type != null) query.append("proxy_type", String(args.proxy_type)) if (args.proxy_type_code != null) query.append("proxy_type_code", String(args.proxy_type_code)) if (sec0 !== undefined) headers.set("x-api-key", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/proxy_services/dict/proxy_lookups${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(dictProxyLookupListResult, await res.json()) };