import {z} from 'zod' export type Amount = {value?: string | undefined, currency?: string | undefined}; export type Image = {attachment_public_uuid?: string | undefined, content_type?: string | undefined, height?: number | undefined, width?: number | undefined}; export type Avatar = {uuid?: string | undefined, anchor_uuid?: string | undefined, image?: Array | undefined, style?: string | undefined}; export type LabelUser = {uuid?: string | undefined, display_name?: string | undefined, country?: string | undefined, avatar?: Avatar | undefined, public_nick_name?: string | undefined}; export type Pointer = {type?: string | undefined, value?: string | undefined, name?: string | undefined, service?: string | undefined}; export type LabelMonetaryAccount = {iban?: string | undefined, display_name?: string | undefined, avatar?: Avatar | undefined, label_user?: LabelUser | undefined, country?: string | undefined, bunq_me?: Pointer | undefined, is_light?: boolean | undefined, swift_bic?: string | undefined, swift_account_number?: string | undefined, transferwise_account_number?: string | undefined, transferwise_bank_code?: string | undefined, merchant_category_code?: string | undefined}; export type AttachmentMonetaryAccountPayment = {id?: number | undefined, monetary_account_id?: number | undefined}; export type DraftPaymentEntry = {amount?: Amount | undefined, counterparty_alias?: LabelMonetaryAccount | undefined, description?: string | undefined, merchant_reference?: string | undefined, attachment?: Array | undefined, id?: number | undefined, alias?: LabelMonetaryAccount | undefined, type?: string | undefined}; export type PaymentArrivalExpected = {status?: string | undefined, time?: string | undefined}; export type Address = {street?: string | undefined, house_number?: string | undefined, po_box?: string | undefined, postal_code?: string | undefined, city?: string | undefined, country?: string | undefined, extra?: string | undefined, mailbox_name?: string | undefined, province?: string | undefined, is_user_address_updated?: boolean | undefined}; export type Geolocation = {latitude?: number | undefined, longitude?: number | undefined, altitude?: number | undefined, radius?: number | undefined}; export type RequestInquiryReference = {type?: string | undefined, id?: number | undefined}; export type Error = Array<{error_description?: string | undefined, error_description_translated?: string | undefined}>; export type PaymentBatchAnchoredPayment = {Payment?: Array | undefined}; export type PaymentBatch = {payments?: PaymentBatchAnchoredPayment | undefined}; export type GinmonTransaction = {status?: string | undefined, status_description?: string | undefined, status_description_translated?: string | undefined, amount_billing?: Amount | undefined, amount_billing_original?: Amount | undefined, isin?: string | undefined, external_identifier?: string | undefined, label_user?: LabelUser | undefined, label_monetary_account?: LabelMonetaryAccount | undefined, counter_label_monetary_account?: LabelMonetaryAccount | undefined, event_id?: number | undefined}; export type PaymentAutoAllocateInstance = {id?: number | undefined, created?: string | undefined, updated?: string | undefined, payment_auto_allocate_id?: number | undefined, status?: string | undefined, error_message?: Array | undefined, payment_batch?: PaymentBatch | undefined, payment_id?: number | undefined, all_ginmon_transaction_order?: Array | undefined}; export type PaymentSuspendedOutgoing = {status?: string | undefined, monetary_account_id?: string | undefined, time_execution?: string | undefined}; export type PaymentFee = {value?: string | undefined, currency?: string | undefined, invoice_id?: number | undefined}; export type Payment = {amount?: Amount | undefined, counterparty_alias?: LabelMonetaryAccount | undefined, description?: string | undefined, attachment?: Array | undefined, merchant_reference?: string | undefined, allow_bunqto?: boolean | undefined, id?: number | undefined, created?: string | undefined, updated?: string | undefined, monetary_account_id?: number | undefined, alias?: LabelMonetaryAccount | undefined, type?: string | undefined, sub_type?: string | undefined, payment_arrival_expected?: PaymentArrivalExpected | undefined, bunqto_status?: string | undefined, bunqto_sub_status?: string | undefined, bunqto_share_url?: string | undefined, bunqto_expiry?: string | undefined, bunqto_time_responded?: string | undefined, batch_id?: number | undefined, scheduled_id?: number | undefined, address_shipping?: Address | undefined, address_billing?: Address | undefined, geolocation?: Geolocation | undefined, request_reference_split_the_bill?: Array | undefined, balance_after_mutation?: Amount | undefined, payment_auto_allocate_instance?: PaymentAutoAllocateInstance | undefined, payment_suspended_outgoing?: PaymentSuspendedOutgoing | undefined, payment_fee?: PaymentFee | undefined}; export type ScheduleAnchorObject = {Payment?: Payment | undefined, PaymentBatch?: PaymentBatch | undefined}; export type Schedule = {time_start?: string | undefined, time_end?: string | undefined, recurrence_unit?: string | undefined, recurrence_size?: number | undefined, status?: string | undefined, object?: ScheduleAnchorObject | undefined}; export type DraftPayment = {status?: string | undefined, entries: Array, previous_updated_timestamp?: string | undefined, number_of_required_accepts: number, schedule?: Schedule | undefined}; export type UpdateApiUserUserIDMonetaryAccountMonetaryAccountIDDraftPaymentItemIdArgs = {userID: number, 'monetary-accountID': number, itemId: number, 'Cache-Control'?: string | undefined, 'User-Agent': string, 'X-Bunq-Language'?: string | undefined, 'X-Bunq-Region'?: string | undefined, 'X-Bunq-Client-Request-Id'?: string | undefined, 'X-Bunq-Geolocation'?: string | undefined, 'X-Bunq-Client-Authentication': string, body: DraftPayment}; export type UpdateApiUserUserIDMonetaryAccountMonetaryAccountIDDraftPaymentItemIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const draftPaymentUpdate = z.object({id: 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 }; /** * PUT /user/{userID}/monetary-account/{monetary-accountID}/draft-payment/{itemId} */ export const updateApiUserUserIDMonetaryAccountMonetaryAccountIDDraftPaymentItemId = async (args: UpdateApiUserUserIDMonetaryAccountMonetaryAccountIDDraftPaymentItemIdArgs, options?: UpdateApiUserUserIDMonetaryAccountMonetaryAccountIDDraftPaymentItemIdOptions) => { const {baseUrl = "https://public-api.sandbox.bunq.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Cache-Control'] != null) headers.set("Cache-Control", String(args['Cache-Control'])) if (args['User-Agent'] != null) headers.set("User-Agent", String(args['User-Agent'])) if (args['X-Bunq-Language'] != null) headers.set("X-Bunq-Language", String(args['X-Bunq-Language'])) if (args['X-Bunq-Region'] != null) headers.set("X-Bunq-Region", String(args['X-Bunq-Region'])) if (args['X-Bunq-Client-Request-Id'] != null) headers.set("X-Bunq-Client-Request-Id", String(args['X-Bunq-Client-Request-Id'])) if (args['X-Bunq-Geolocation'] != null) headers.set("X-Bunq-Geolocation", String(args['X-Bunq-Geolocation'])) if (args['X-Bunq-Client-Authentication'] != null) headers.set("X-Bunq-Client-Authentication", String(args['X-Bunq-Client-Authentication'])) const url = `${baseUrl.replace(/\/+$/, '')}/user/${encodeURIComponent(String(args.userID))}/monetary-account/${encodeURIComponent(String(args['monetary-accountID']))}/draft-payment/${encodeURIComponent(String(args.itemId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(draftPaymentUpdate, await res.json()) };