import {z} from 'zod' export type Iso4217Code = 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BOV' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHE' | 'CHF' | 'CHW' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'COU' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MXV' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SLE' | 'SEK' | 'SGD' | 'SHP' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'USN' | 'UYI' | 'UYU' | 'UYW' | 'UZS' | 'VED' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XAG' | 'XAU' | 'XBA' | 'XBB' | 'XBC' | 'XBD' | 'XCD' | 'XDR' | 'XOF' | 'XPD' | 'XPF' | 'XPT' | 'XSU' | 'XTS' | 'XUA' | 'XXX' | 'YER' | 'ZAR' | 'ZMW' | 'ZWG' | 'ZWL'; export type InternationalPaymentPurposeCode = 'advertising' | 'advisor_fees' | 'construction' | 'education' | 'exports' | 'family' | 'fund_investment' | 'goods' | 'hotel' | 'insurance_claims' | 'insurance_premium' | 'loan_repayment' | 'medical' | 'other_fees' | 'property_purchase' | 'property_rental' | 'royalties' | 'services' | 'tax' | 'transfer' | 'travel' | 'utilities' | 'business_insurance' | 'delivery' | 'office' | 'share_investment' | 'transportation' | 'ACM' | 'AES' | 'AFA' | 'AFL' | 'ALW' | 'ATS' | 'BON' | 'CCP' | 'CEA' | 'CEL' | 'CHC' | 'CIN' | 'COM' | 'COP' | 'CRP' | 'DCP' | 'DIV' | 'DLA' | 'DLF' | 'DLL' | 'DOE' | 'DSA' | 'DSF' | 'DSL' | 'EDU' | 'EMI' | 'EOS' | 'FAM' | 'FDA' | 'FDL' | 'FIA' | 'FIL' | 'FIS' | 'FSA' | 'FSL' | 'GDE' | 'GDI' | 'GMS' | 'GOS' | 'GRI' | 'IFS' | 'IGD' | 'IGT' | 'IID' | 'INS' | 'IOD' | 'IOL' | 'IPC' | 'IPO' | 'IRP' | 'IRW' | 'ISH' | 'ISL' | 'ISS' | 'ITS' | 'LAS' | 'LDL' | 'LDS' | 'LEA' | 'LEL' | 'LIP' | 'LLA' | 'LLL' | 'LNC' | 'LND' | 'MCR' | 'MWI' | 'MWO' | 'MWP' | 'OAT' | 'OTS' | 'OVT' | 'PEN' | 'PIN' | 'PIP' | 'PMS' | 'POR' | 'POS' | 'PPA' | 'PPL' | 'PRP' | 'PRR' | 'PRS' | 'PRW' | 'RDS' | 'RFS' | 'RLS' | 'RNT' | 'SAA' | 'SAL' | 'SCO' | 'SLA' | 'SLL' | 'STR' | 'STS' | 'SVI' | 'SVO' | 'SVP' | 'TCP' | 'TCR' | 'TCS' | 'TKT' | 'TOF' | 'TTS' | 'UTL'; export type CreateInternationalPaymentRequest = {contact_id: string, recipient_amount?: (number | string | null) | undefined, source_amount?: (number | string | null) | undefined, recipient_currency: Iso4217Code, purpose: string, purpose_code?: (InternationalPaymentPurposeCode | null) | undefined, invoice_number?: (string | null) | undefined, invoice_date?: (string | null) | undefined, reference?: (string | null) | undefined, metadata?: ({[key: string]: string} | null) | undefined}; export type CreateApiAccountsAccountIdInternationalArgs = {account_id: string, 'Idempotency-Key': string, 'x-entity-id'?: string | undefined, body: CreateInternationalPaymentRequest}; export type CreateApiAccountsAccountIdInternationalOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const internationalPaymentRequestStatus = z.enum(["processing", "pending_approval"]); export const iso4217Code = z.enum(["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRU", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SLE", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "UYI", "UYU", "UYW", "UZS", "VED", "VES", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "XSU", "XTS", "XUA", "XXX", "YER", "ZAR", "ZMW", "ZWG", "ZWL"]); export const createInternationalPaymentResponse = z.object({approval_id: z.string(), status: internationalPaymentRequestStatus, contact_id: z.string(), recipient_amount: z.string(), recipient_currency: iso4217Code, source_amount: z.string(), fee_amount: z.string(), total_amount: z.string(), created_time: z.number().int(), message: z.string().nullable().optional(), metadata: z.record(z.string(), z.string().max(200)).nullable().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 }; /** * Create International Payment * * POST /accounts/{account_id}/international */ export const createApiAccountsAccountIdInternational = async (args: CreateApiAccountsAccountIdInternationalArgs, options?: CreateApiAccountsAccountIdInternationalOptions) => { const {baseUrl = "https://api.meow.com/v1", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) if (args['x-entity-id'] != null) headers.set("x-entity-id", String(args['x-entity-id'])) if (apiKeyAuth !== undefined) headers.set("x-api-key", apiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/accounts/${encodeURIComponent(String(args.account_id))}/international${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(createInternationalPaymentResponse, await res.json()) };