import {z} from 'zod' export type GetApiApiV20AccountsAccountIdTransactionsPaginatedArgs = {version: string, accountId: string, transactionId?: string | undefined, referenceId?: string | undefined, externalId?: string | undefined, type?: ('Credit' | 'Debit') | undefined, currency?: ('BRL' | 'BRZ' | 'BTC' | 'ETH' | 'USDC' | 'USDT' | 'XRP' | 'ARS' | 'SOL' | 'USD' | 'XLM' | 'ARZ' | 'EUZ' | 'MXZ' | 'COZ' | 'CLZ' | 'PGZ' | 'UYZ' | 'PEZ' | 'EUR' | 'CHF' | 'GBP' | 'LINK' | 'DOT' | 'AAVE' | 'UNI' | 'AVAX' | 'FTM' | 'LUNA' | 'POL' | 'ATOM' | 'BNB' | 'ZAR' | 'BUSD' | 'RNDZ' | 'MXN' | 'COP' | 'OP' | 'ARB' | 'PEPE' | 'SHIB' | 'DOGE' | 'SUI' | 'GALA' | 'SNX' | 'GMX' | 'INJ' | 'LDO' | 'APE' | 'ADA' | 'NEAR' | 'DYN' | 'XTZ' | 'MANA' | 'RDNT' | 'CAKE' | 'DYDX' | 'GLMR' | 'RBTC' | 'CRV' | 'BAL' | 'MKR' | 'TRX' | 'CRO' | 'APTOS' | 'RDOC' | 'ZENIQ' | 'RIF' | 'STBRZ' | 'EURC' | 'MNT' | 'NGN' | 'XAF' | 'XOF' | 'EGP' | 'KES' | 'BWP' | 'GHS' | 'ZMW' | 'GNF' | 'UGX' | 'TON' | 'CLP' | 'CHZ' | 'GNO' | 'DAI' | 'XDAI') | undefined, taxIdCountry?: ('ALB' | 'AND' | 'AZE' | 'ARG' | 'AUS' | 'AUT' | 'BHR' | 'ARM' | 'BEL' | 'BOL' | 'BIH' | 'BRA' | 'BGR' | 'BLR' | 'CAN' | 'CHL' | 'CHN' | 'TWN' | 'COL' | 'CRI' | 'HRV' | 'CUB' | 'CYP' | 'CZE' | 'DNK' | 'DOM' | 'ECU' | 'SLV' | 'EST' | 'FRO' | 'FLK' | 'FIN' | 'FRA' | 'GUF' | 'GEO' | 'DEU' | 'GRC' | 'GTM' | 'GUY' | 'HKG' | 'HUN' | 'ISL' | 'IND' | 'IDN' | 'IRL' | 'ISR' | 'ITA' | 'JPN' | 'KAZ' | 'KOR' | 'LVA' | 'LTU' | 'LUX' | 'MYS' | 'MLT' | 'MUS' | 'MEX' | 'MCO' | 'MDA' | 'MNE' | 'NLD' | 'NZL' | 'NGA' | 'NOR' | 'PAK' | 'PRY' | 'PER' | 'PHL' | 'POL' | 'PRT' | 'ROU' | 'RUS' | 'SMR' | 'SRB' | 'SVK' | 'SVN' | 'ZAF' | 'ESP' | 'SUR' | 'SWE' | 'CHE' | 'THA' | 'ARE' | 'TUR' | 'UKR' | 'MKD' | 'GBR' | 'USA' | 'URY' | 'UZB' | 'VEN') | undefined, taxId?: string | undefined, beginDate?: string | undefined, endDate?: string | undefined, pageNumber?: number | undefined, pageSize?: number | undefined, Authorization: string}; export type GetApiApiV20AccountsAccountIdTransactionsPaginatedOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiApiV20AccountsAccountIdTransactionsPaginatedResponse = z.array(z.object({amount: z.object({amount: z.number().int().optional(), currency: z.string().optional()}).optional(), amountNet: z.unknown(), transactionDescription: z.object({description: z.string().optional(), name: z.string().optional(), taxId: z.string().optional(), taxIdCountry: z.string().optional()}).optional(), date: z.string().optional(), dateDetailed: z.string().optional(), type: z.string().optional(), transactionId: z.string().optional(), transactionHash: z.unknown(), wallet: z.unknown(), counterpartWallet: z.unknown(), counterpart: z.unknown(), referenceId: z.unknown(), blockchain: z.unknown()})); 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 }; /** * Retrieve an Account Statement with Paginated List * * GET /api/v2.0/accounts/{accountId}/transactionsPaginated */ export const getApiApiV20AccountsAccountIdTransactionsPaginated = async (args: GetApiApiV20AccountsAccountIdTransactionsPaginatedArgs, options?: GetApiApiV20AccountsAccountIdTransactionsPaginatedOptions) => { const {baseUrl = "https://sandbox-api-baasic.transfero.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.transactionId != null) query.append("transactionId", String(args.transactionId)) if (args.referenceId != null) query.append("referenceId", String(args.referenceId)) if (args.externalId != null) query.append("externalId", String(args.externalId)) if (args.type != null) query.append("type", String(args.type)) if (args.currency != null) query.append("currency", String(args.currency)) if (args.taxIdCountry != null) query.append("taxIdCountry", String(args.taxIdCountry)) if (args.taxId != null) query.append("taxId", String(args.taxId)) if (args.beginDate != null) query.append("beginDate", String(args.beginDate)) if (args.endDate != null) query.append("endDate", String(args.endDate)) if (args.pageNumber != null) query.append("pageNumber", String(args.pageNumber)) if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2.0/accounts/${encodeURIComponent(String(args.accountId))}/transactionsPaginated${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(getApiApiV20AccountsAccountIdTransactionsPaginatedResponse, await res.json()) };