import {z} from 'zod' export type GetApiAccountsAccountIdPaymentNetworksArgs = {account_id: string, limit?: (number | null) | undefined, offset?: (string | null) | undefined, 'x-entity-id'?: string | undefined}; export type GetApiAccountsAccountIdPaymentNetworksOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const pageMetadata = z.object({nextOffset: z.string().nullable().optional()}); export const paymentNetworkType = z.enum(["US_ACH", "US_FEDWIRE", "US_CHIPS", "CA_ACSS", "CA_LVTS", "USDC", "USDT"]); export const blockchainNetwork = z.enum(["ARBITRUM", "AVALANCHE_C_CHAIN", "BASE", "ETHEREUM", "OPTIMISM", "POLYGON", "SOLANA", "STELLAR", "SUI", "TEMPO", "TRON", "XDC"]); export const depositSettlementRail = z.enum(["US_FEDNOW", "US_FEDWIRE"]); export const accountType = z.enum(["BROKERAGEPRODUCT", "CHECKING", "MONEYMARKET", "SAVINGS", "TAXABLE"]); export const intermediaryBankSWIFT = z.object({swift: z.string(), bank_name: z.string(), bank_address: z.string()}); export const foreignCurrencyWireBeneficiary = z.object({name: z.string(), address: z.string(), account_number: z.string(), payment_reference: z.string()}); 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 foreignCurrencyWireAgent = z.object({bank_name: z.string(), swift_code: z.string().nullable().optional(), account_number: z.string().nullable().optional(), iban: z.string().nullable().optional(), transit_number: z.string().nullable().optional(), national_clearing_code: z.string().nullable().optional()}); export const foreignCurrencyWireInstruction = z.object({currency: iso4217Code, intermediary_agent_2: foreignCurrencyWireAgent, intermediary_agent_1: foreignCurrencyWireAgent, creditor_agent: foreignCurrencyWireAgent, remittance_info: z.string().nullable().optional()}); export const foreignCurrencyWireInstructions = z.object({beneficiary: foreignCurrencyWireBeneficiary, instructions: z.array(foreignCurrencyWireInstruction)}); export const accountPaymentNetwork = z.object({bankId: z.string().nullable().optional(), identifier: z.string().nullable().optional(), type: paymentNetworkType, transferIn: z.boolean(), transferOut: z.boolean(), network: blockchainNetwork.nullable().optional(), settlementRail: depositSettlementRail.nullable().optional(), bankName: z.string().nullable().optional(), bankAddress: z.string().nullable().optional(), beneficiaryName: z.string().nullable().optional(), beneficiaryAddress: z.string().nullable().optional(), accountType: accountType.nullable().optional(), swiftCode: z.string().nullable().optional(), intermediaryBank: intermediaryBankSWIFT.nullable().optional(), fiToFiReference: z.string().nullable().optional(), foreignCurrencyWireInstructions: foreignCurrencyWireInstructions.nullable().optional()}); export const accountPaymentNetworkList = z.object({page: pageMetadata.nullable().optional(), paymentNetworks: z.array(accountPaymentNetwork)}); 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 Payment Networks for an Account * * GET /accounts/{account_id}/payment-networks */ export const getApiAccountsAccountIdPaymentNetworks = async (args: GetApiAccountsAccountIdPaymentNetworksArgs, options?: GetApiAccountsAccountIdPaymentNetworksOptions) => { const {baseUrl = "https://api.meow.com/v1", fetch: fetchFn = fetch, apiKeyAuth} = 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.offset != null) query.append("offset", String(args.offset)) 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))}/payment-networks${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(accountPaymentNetworkList, await res.json()) };