import {z} from 'zod' export type Amount = {value?: string | undefined, currency?: 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 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 AttachmentUrl = {type?: string | undefined, url?: string | undefined}; export type Attachment = {description?: string | undefined, content_type?: string | undefined, urls?: Array | 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 RequestResponse = {amount_responded?: Amount | undefined, status?: string | undefined, address_shipping?: Address | undefined, address_billing?: Address | undefined, currency_conversion_quote_id?: number | undefined, id?: number | undefined, created?: string | undefined, updated?: string | undefined, time_responded?: string | undefined, time_expiry?: string | undefined, time_refund_requested?: string | undefined, time_refunded?: string | undefined, user_refund_requested?: LabelUser | undefined, monetary_account_id?: number | undefined, amount_inquired?: Amount | undefined, description?: string | undefined, alias?: LabelMonetaryAccount | undefined, counterparty_alias?: LabelMonetaryAccount | undefined, attachment?: Array | undefined, minimum_age?: number | undefined, require_address?: string | undefined, geolocation?: Geolocation | undefined, type?: string | undefined, sub_type?: string | undefined, redirect_url?: string | undefined, credit_scheme_identifier?: string | undefined, mandate_identifier?: string | undefined, registration_action?: string | undefined, eligible_whitelist_id?: number | undefined, request_reference_split_the_bill?: Array | undefined, event_id?: number | undefined, monetary_account_preferred_id?: number | undefined}; export type UpdateApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseItemIdArgs = {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: RequestResponse}; export type UpdateApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseItemIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const bunqId = z.object({id: z.number().int().optional()}); export const requestResponseUpdate = z.object({Id: bunqId.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}/request-response/{itemId} */ export const updateApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseItemId = async (args: UpdateApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseItemIdArgs, options?: UpdateApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseItemIdOptions) => { 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']))}/request-response/${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(requestResponseUpdate, await res.json()) };