import {z} from 'zod' export type Address = {city?: string | undefined, country?: string | undefined, county?: string | undefined, state?: string | undefined, street?: string | undefined, street_etc?: string | undefined, zip?: string | undefined}; export type DBMSISlice = Array<{[key: string]: unknown}>; export type DBStringSlice = Array; export type Business = {cancel_policy?: string | undefined, cancel_policy_combo_bookings?: string | undefined, cancel_text?: string | undefined, checkout_questions?: DBMSISlice | undefined, consigned_keep_pct_addon_fee?: number | undefined, consigned_keep_pct_cc_fee?: number | undefined, consigned_keep_pct_insurance_fee?: number | undefined, consigned_pay_pct?: number | undefined, consigned_pay_pct_generator?: number | undefined, consigned_pay_pct_mileage?: number | undefined, description?: string | undefined, fax?: string | undefined, ga4_id?: string | undefined, google_analytics_id?: (string | null) | undefined, google_tag_manager_id?: (string | null) | undefined, hide_rentals?: boolean | undefined, house_rules?: string | undefined, localized_languages?: DBStringSlice | undefined, name?: string | undefined, outdoorsy_display_name?: string | undefined, phone?: string | undefined, segment_token?: string | undefined, terms_of_service?: string | undefined, website?: string | undefined}; export type DepositAccount = {id?: string | undefined, last_four?: string | undefined, name?: string | undefined}; export type Vendor = {address?: Address | undefined, bank_address?: string | undefined, birth_date?: string | undefined, business?: Business | undefined, currency?: string | undefined, debit_agreement_ip?: string | undefined, debit_agreement_shown_and_accepted?: boolean | undefined, debit_agreement_user_agent?: string | undefined, deposit_account?: DepositAccount | undefined, email?: string | undefined, external_accounts?: number | undefined, first_name?: string | undefined, fund_id?: string | undefined, id?: string | undefined, last_name?: string | undefined, merchant_of_record?: boolean | undefined, missing_fields?: Array | undefined, nickname?: string | undefined, no_additional_owners?: boolean | undefined, payouts_enabled?: boolean | undefined, personal_id?: string | undefined, phone?: string | undefined, reference_number?: string | undefined, sort_code?: string | undefined, ssn_last_four?: string | undefined, status?: string | undefined, support_phone?: string | undefined, type?: string | undefined, url?: string | undefined, verified?: boolean | undefined}; export type VendorBody = {token?: string | undefined, vendor?: Vendor | undefined}; export type PatchApiUsersBanksIdArgs = {id: number, body: VendorBody}; export type PatchApiUsersBanksIdOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const paymentAddress = z.object({city: z.string().optional(), country: z.string().optional(), state: z.string().optional(), street: z.string().optional(), street_etc: z.string().optional(), zip: z.string().optional()}); export const dBInterfaceMap = z.unknown(); export const dBStringSlice = z.array(z.string()); 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 paymentProcessingInfo = z.object({address: paymentAddress.optional(), archived: z.boolean().optional(), bank_address: z.string().optional(), bank_last_four: z.string().optional(), bank_name: z.string().optional(), base_currency: z.string().optional(), can_accept_payments: z.boolean().optional(), can_archive_bank: z.boolean().optional(), can_send_payments: z.boolean().optional(), capabilities: dBInterfaceMap.optional(), created: z.string().optional(), customer_id: z.string().optional(), debit_agreement_date: z.string().optional(), deposits_disabled: z.boolean().optional(), form: z.record(z.string(), z.unknown()).optional(), fund_id: z.string().optional(), gateway_type: z.string().optional(), id: z.number().int().optional(), managed_account_id: z.string().optional(), missing_fields: dBStringSlice.optional(), missing_fields_change_description: z.array(z.string()).optional(), needs_migration: z.boolean().optional(), nickname: z.string().optional(), notes: z.string().optional(), owner_id: z.number().int().optional(), payment_processor: paymentProcessor.optional(), phone: z.string().optional(), reference_number: z.string().optional(), sort_code: z.string().optional(), status: z.string().optional(), support_phone: z.string().optional(), updated: 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 }; /** * Updates the specified connected bank * * PATCH /users/banks/{id} * * Also accepts auth: API-Key */ export const patchApiUsersBanksId = async (args: PatchApiUsersBanksIdArgs, options: PatchApiUsersBanksIdOptions) => { 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(/\/+$/, '')}/users/banks/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(paymentProcessingInfo, await res.json()) };