import {z} from 'zod' export type SandboxSimulateCapabilitiesDto = {capabilities: Array<'USD_ACH_PAYIN' | 'USD_ACH_PAYOUT' | 'USD_WIRE_PAYIN' | 'USD_WIRE_PAYOUT' | 'USD_BALANCE' | 'USD_YIELD' | 'SWIFT_PAYIN' | 'SWIFT_PAYOUT' | 'STABLECOIN_PAYIN' | 'STABLECOIN_PAYOUT' | 'STABLECOIN_SWAPS' | 'AED_FX_PAYOUT' | 'AUD_FX_PAYOUT' | 'BHD_FX_PAYOUT' | 'BOB_FX_PAYOUT' | 'BRL_FX_PAYOUT' | 'CLP_FX_PAYOUT' | 'CNY_FX_PAYOUT' | 'COP_FX_PAYOUT' | 'DOP_FX_PAYOUT' | 'EGP_FX_PAYOUT' | 'EUR_FX_PAYOUT' | 'GBP_FX_PAYOUT' | 'HKD_FX_PAYOUT' | 'IDR_FX_PAYOUT' | 'INR_FX_PAYOUT' | 'JPY_FX_PAYOUT' | 'KRW_FX_PAYOUT' | 'KWD_FX_PAYOUT' | 'MXN_FX_PAYOUT' | 'MYR_FX_PAYOUT' | 'PEN_FX_PAYOUT' | 'PHP_FX_PAYOUT' | 'PYG_FX_PAYOUT' | 'QAR_FX_PAYOUT' | 'SAR_FX_PAYOUT' | 'SGD_FX_PAYOUT' | 'THB_FX_PAYOUT' | 'TRY_FX_PAYOUT' | 'TWD_FX_PAYOUT' | 'USD_FX_PAYOUT' | 'VND_FX_PAYOUT'>}; export type UpdateApiV1SandboxCustomersIdCapabilitiesArgs = {'X-API-Key'?: string | undefined, id: string, body: SandboxSimulateCapabilitiesDto}; export type UpdateApiV1SandboxCustomersIdCapabilitiesOptions = {baseUrl?: string | undefined, bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const customerCapabilityStateDto = z.object({capability: z.enum(["USD_ACH_PAYIN", "USD_ACH_PAYOUT", "USD_WIRE_PAYIN", "USD_WIRE_PAYOUT", "USD_BALANCE", "USD_YIELD", "SWIFT_PAYIN", "SWIFT_PAYOUT", "STABLECOIN_PAYIN", "STABLECOIN_PAYOUT", "STABLECOIN_SWAPS", "AED_FX_PAYOUT", "AUD_FX_PAYOUT", "BHD_FX_PAYOUT", "BOB_FX_PAYOUT", "BRL_FX_PAYOUT", "CLP_FX_PAYOUT", "CNY_FX_PAYOUT", "COP_FX_PAYOUT", "DOP_FX_PAYOUT", "EGP_FX_PAYOUT", "EUR_FX_PAYOUT", "GBP_FX_PAYOUT", "HKD_FX_PAYOUT", "IDR_FX_PAYOUT", "INR_FX_PAYOUT", "JPY_FX_PAYOUT", "KRW_FX_PAYOUT", "KWD_FX_PAYOUT", "MXN_FX_PAYOUT", "MYR_FX_PAYOUT", "PEN_FX_PAYOUT", "PHP_FX_PAYOUT", "PYG_FX_PAYOUT", "QAR_FX_PAYOUT", "SAR_FX_PAYOUT", "SGD_FX_PAYOUT", "THB_FX_PAYOUT", "TRY_FX_PAYOUT", "TWD_FX_PAYOUT", "USD_FX_PAYOUT", "VND_FX_PAYOUT"]), status: z.enum(["READY", "IN_REVIEW", "UNAVAILABLE"])}); export const customerCapabilitiesResponseDto = z.object({id: z.string(), capabilities: z.array(customerCapabilityStateDto)}); 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 }; /** * Simulate customer capabilities * * PUT /v1/sandbox/customers/{id}/capabilities */ export const updateApiV1SandboxCustomersIdCapabilities = async (args: UpdateApiV1SandboxCustomersIdCapabilitiesArgs, options?: UpdateApiV1SandboxCustomersIdCapabilitiesOptions) => { const {baseUrl = "https://sandbox.api.infinite.dev", fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['X-API-Key'] != null) headers.set("X-API-Key", String(args['X-API-Key'])) if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/sandbox/customers/${encodeURIComponent(String(args.id))}/capabilities${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(customerCapabilitiesResponseDto, await res.json()) };