import {z} from 'zod' export type CreateApiWalletsAccountGetTransactionsByIdArgs = {'api-key': string, Authorization: string, body: {userId: string, accountId: string, txId: string}}; export type CreateApiWalletsAccountGetTransactionsByIdOptions = {baseUrl?: string | undefined, sec0?: string | undefined, sec1?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiWalletsAccountGetTransactionsByIdResponse = z.object({transactions: z.array(z.object({id: z.string().optional(), credit: z.number().int().optional(), debit: z.number().int().optional(), timestamp: z.string().optional(), txType: z.string().optional(), hash: z.string().optional(), otherCryptoIdentifier: z.string().optional(), feeBaseCurrency: z.number().optional(), nonFpFeeBaseCurrency: z.number().int().optional(), balanceBefore: z.object({amount: z.number().int().optional(), currency: z.string().optional()}).optional(), balanceAfter: z.object({amount: z.number().int().optional(), currency: z.string().optional()}).optional()})).optional(), count: z.number().int().optional(), total: z.number().int().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 }; /** * Get Transactions By Id * * POST /wallets/account/get-transactions-by-id */ export const createApiWalletsAccountGetTransactionsById = async (args: CreateApiWalletsAccountGetTransactionsByIdArgs, options?: CreateApiWalletsAccountGetTransactionsByIdOptions) => { const {baseUrl = "https://www.sandbox.striga.com/api/v1", fetch: fetchFn = fetch, sec0, sec1} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['api-key'] != null) headers.set("api-key", String(args['api-key'])) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (sec0 !== undefined) headers.set("api-key", sec0) if (sec1 !== undefined) headers.set("Authorization", sec1) const url = `${baseUrl.replace(/\/+$/, '')}/wallets/account/get-transactions-by-id${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(createApiWalletsAccountGetTransactionsByIdResponse, await res.json()) };