import {z} from 'zod' export type GetApiDepostiDepositIdVerifyArgs = {deposit_id: string, body: {otp: string}}; export type GetApiDepostiDepositIdVerifyOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiDepostiDepositIdVerifyResponse = z.object({status: z.string().optional(), message: z.string().optional(), data: z.object({id: z.string().optional(), object_type: z.string().optional(), card_id: z.unknown(), account_id: z.unknown(), source_account_id: z.unknown(), account_type: z.unknown(), address_id: z.unknown(), type: z.string().optional(), rail: z.string().optional(), currency: z.string().optional(), currency_source: z.string().optional(), amount: z.number().int().optional(), amount_source: z.number().int().optional(), amount_settled: z.number().int().optional(), fee: z.number().int().optional(), settlement_type: z.string().optional(), settlement_rate: z.number().int().optional(), payer: z.object({account_name: z.unknown(), account_number: z.unknown(), bank_name: z.unknown(), routing_rail: z.unknown(), routing_type: z.unknown(), routing_number: z.unknown(), bank_code: z.unknown(), imad: z.unknown(), trace_number: z.unknown(), session_id: z.unknown(), network: z.unknown(), chain_hash: z.unknown(), mobile: z.string().optional(), auth_model: z.string().optional()}).optional(), status: z.string().optional(), created_at: z.string().optional(), updated_at: z.string().optional()}).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 }; /** * Verify Deposit * * GET /deposti/{deposit_id}/verify */ export const getApiDepostiDepositIdVerify = async (args: GetApiDepostiDepositIdVerifyArgs, options?: GetApiDepostiDepositIdVerifyOptions) => { const {baseUrl = "https://api.useoval.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("Authorization", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/deposti/${encodeURIComponent(String(args.deposit_id))}/verify${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", 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(getApiDepostiDepositIdVerifyResponse, await res.json()) };