import {z} from 'zod' export type GetApiApiV1AdminPostProcessorLogsLogIdArgs = {logId: string}; export type GetApiApiV1AdminPostProcessorLogsLogIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const adminPostProcessorLogResponse = z.object({success: z.boolean(), data: z.object({id: z.string(), transaction_id: z.string().nullable(), merchant_id: z.string(), action: z.union([z.literal("FEE_TRANSFER"), z.literal("CURRENCY_CONVERSION"), z.literal("PAYOUT"), z.literal("REFUND_RETENTION"), z.literal("MANUAL")]), status: z.union([z.literal("INITIATED"), z.literal("COMPLETED"), z.literal("FAILED")]), from_currency: z.string(), to_currency: z.string().nullable(), amount: z.string(), converted_amount: z.string().nullable(), exchange_rate: z.string().nullable(), tm_transaction_id: z.string().nullable(), reference: z.string().nullable(), error_message: z.string().nullable(), source_account_id: z.string().nullable(), source_account_type: z.union([z.literal("MERCHANT_BANK_ACCOUNT"), z.literal("FEE_ACCOUNT")]).nullable(), destination_account_id: z.string().nullable(), destination_account_type: z.union([z.literal("MERCHANT_BANK_ACCOUNT"), z.literal("FEE_ACCOUNT"), z.literal("CUSTOMER_BANK_ACCOUNT")]).nullable(), reason: z.string().nullable(), performed_by_user_id: z.string().nullable(), created_at: z.string()})}); 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 a single post-processor log entry by ID (admin only) * * GET /api/v1/admin/post-processor-logs/{logId} */ export const getApiApiV1AdminPostProcessorLogsLogId = async (args: GetApiApiV1AdminPostProcessorLogsLogIdArgs, options?: GetApiApiV1AdminPostProcessorLogsLogIdOptions) => { const {baseUrl = "https://core.quidkey.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/admin/post-processor-logs/${encodeURIComponent(String(args.logId))}${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(adminPostProcessorLogResponse, await res.json()) };