import {z} from 'zod' export type DBInterfaceMap = unknown; export type PaymentProcessorName = string; export type PaymentProcessor = {country?: string | undefined, external_processor?: string | undefined, external_processor_id?: string | undefined, name?: PaymentProcessorName | undefined}; export type Transaction = {actual_deposit_date?: string | undefined, adjustment?: number | undefined, amount?: number | undefined, auto_deposit?: boolean | undefined, available?: string | undefined, booking_id?: number | undefined, brand?: string | undefined, can_delete?: boolean | undefined, can_finance_sync?: boolean | undefined, can_refund?: boolean | undefined, can_retry?: boolean | undefined, can_reverse_transfer?: boolean | undefined, can_sync?: boolean | undefined, can_transfer?: boolean | undefined, cc_fee?: number | undefined, charged?: string | undefined, created?: string | undefined, created_by_id?: number | undefined, deposit_date?: string | undefined, description?: string | undefined, display_charge_type?: string | undefined, display_payment_processor_name?: string | undefined, display_type?: string | undefined, dispute_reason?: (string | null) | undefined, dispute_status?: (string | null) | undefined, disputed?: boolean | undefined, expected_deposit_date?: string | undefined, failed?: boolean | undefined, fraudulent?: boolean | undefined, fx_fee?: number | undefined, id?: number | undefined, is_refund?: boolean | undefined, last_four?: string | undefined, original_charge_id?: Transaction | undefined, our_fee?: number | undefined, outdoorsy_fee?: number | undefined, owner_federal_withholding_tax?: number | undefined, owner_fee?: number | undefined, owner_integrations_fee?: (number | null) | undefined, owner_quebec_sales_tax?: number | undefined, paid?: boolean | undefined, payment_meta?: DBInterfaceMap | undefined, payment_processor?: PaymentProcessor | undefined, payment_source?: string | undefined, processor_settlement_id?: (string | null) | undefined, recipient_id?: number | undefined, refund_source?: string | undefined, refunded?: number | undefined, refunded_cc_fee?: number | undefined, refunded_fee?: number | undefined, refunded_fx_fee?: number | undefined, refunded_outdoorsy_fee?: number | undefined, refunded_owner_federal_withholding_tax?: number | undefined, refunded_owner_fee?: number | undefined, refunded_owner_integrations_fee?: (number | null) | undefined, refunded_owner_quebec_sales_tax?: number | undefined, refunded_service_fee?: number | undefined, retry_payout_id?: Transaction | undefined, sales_tax?: number | undefined, service_fee?: number | undefined, status?: string | undefined, stripe_fee?: number | undefined, stripe_fee_refund?: number | undefined, stripe_id?: string | undefined, transfer?: Transaction | undefined, type?: string | undefined}; export type CreateApiBookingsBookingIdTransactionsArgs = {booking_id: number, body: Transaction}; export type CreateApiBookingsBookingIdTransactionsOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const dBInterfaceMap = z.unknown(); export const paymentProcessorName = z.string(); export const paymentProcessor = z.object({country: z.string().optional(), external_processor: z.string().optional(), external_processor_id: z.string().optional(), name: paymentProcessorName.optional()}); export const transaction: z.ZodType = z.object({actual_deposit_date: z.string().optional(), adjustment: z.number().int().optional(), amount: z.number().int().optional(), auto_deposit: z.boolean().optional(), available: z.string().optional(), booking_id: z.number().int().optional(), brand: z.string().optional(), can_delete: z.boolean().optional(), can_finance_sync: z.boolean().optional(), can_refund: z.boolean().optional(), can_retry: z.boolean().optional(), can_reverse_transfer: z.boolean().optional(), can_sync: z.boolean().optional(), can_transfer: z.boolean().optional(), cc_fee: z.number().int().optional(), charged: z.string().optional(), created: z.string().optional(), created_by_id: z.number().int().optional(), deposit_date: z.string().optional(), description: z.string().optional(), display_charge_type: z.string().optional(), display_payment_processor_name: z.string().optional(), display_type: z.string().optional(), dispute_reason: z.string().nullable().optional(), dispute_status: z.string().nullable().optional(), disputed: z.boolean().optional(), expected_deposit_date: z.string().optional(), failed: z.boolean().optional(), fraudulent: z.boolean().optional(), fx_fee: z.number().int().optional(), id: z.number().int().optional(), is_refund: z.boolean().optional(), last_four: z.string().optional(), original_charge_id: z.lazy(() => transaction.optional()), our_fee: z.number().int().optional(), outdoorsy_fee: z.number().int().optional(), owner_federal_withholding_tax: z.number().int().optional(), owner_fee: z.number().int().optional(), owner_integrations_fee: z.number().int().nullable().optional(), owner_quebec_sales_tax: z.number().int().optional(), paid: z.boolean().optional(), payment_meta: dBInterfaceMap.optional(), payment_processor: paymentProcessor.optional(), payment_source: z.string().optional(), processor_settlement_id: z.string().nullable().optional(), recipient_id: z.number().int().optional(), refund_source: z.string().optional(), refunded: z.number().int().optional(), refunded_cc_fee: z.number().int().optional(), refunded_fee: z.number().int().optional(), refunded_fx_fee: z.number().int().optional(), refunded_outdoorsy_fee: z.number().int().optional(), refunded_owner_federal_withholding_tax: z.number().int().optional(), refunded_owner_fee: z.number().int().optional(), refunded_owner_integrations_fee: z.number().int().nullable().optional(), refunded_owner_quebec_sales_tax: z.number().int().optional(), refunded_service_fee: z.number().int().optional(), retry_payout_id: z.lazy(() => transaction.optional()), sales_tax: z.number().int().optional(), service_fee: z.number().int().optional(), status: z.string().optional(), stripe_fee: z.number().int().optional(), stripe_fee_refund: z.number().int().optional(), stripe_id: z.string().optional(), transfer: z.lazy(() => transaction.optional()), type: z.string().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 }; /** * Create transaction or pending transaction when due date is set * * POST /bookings/{booking_id}/transactions * * Also accepts auth: API-Key */ export const createApiBookingsBookingIdTransactions = async (args: CreateApiBookingsBookingIdTransactionsArgs, options: CreateApiBookingsBookingIdTransactionsOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/bookings/${encodeURIComponent(String(args.booking_id))}/transactions${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(transaction, await res.json()) };