import {z} from 'zod' 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 ShareDetailPayment = {make_payments?: boolean | undefined, make_draft_payments?: boolean | undefined, view_balance?: boolean | undefined, view_old_events?: boolean | undefined, view_new_events?: boolean | undefined}; export type ShareDetailReadOnly = {view_balance?: boolean | undefined, view_old_events?: boolean | undefined, view_new_events?: boolean | undefined}; export type ShareDetailDraftPayment = {make_draft_payments?: boolean | undefined, view_balance?: boolean | undefined, view_old_events?: boolean | undefined, view_new_events?: boolean | undefined}; export type ShareDetail = {payment?: ShareDetailPayment | undefined, read_only?: ShareDetailReadOnly | undefined, draft_payment?: ShareDetailDraftPayment | undefined}; export type CompanyEmployeeSettingAdyenCardTransaction = {pointer_counter_user: Pointer, status?: string | undefined, monetary_account_payout_id?: number | undefined}; export type Amount = {value?: string | undefined, currency?: string | undefined}; export type CardCountryPermission = {country?: string | undefined, expiry_time?: string | undefined, id?: number | undefined}; export type CardPinAssignment = {type?: string | undefined, routing_type?: string | undefined, pin_code?: string | undefined, monetary_account_id?: number | undefined, status?: string | undefined}; export type CardPrimaryAccountNumber = {id?: number | undefined, description?: string | undefined, status?: string | undefined, monetary_account_id?: number | undefined, uuid?: string | undefined, four_digit?: string | undefined, type?: string | undefined}; export type Card = {pin_code?: string | undefined, activation_code?: string | undefined, status?: string | undefined, order_status?: string | undefined, card_limit?: Amount | undefined, card_limit_atm?: Amount | undefined, country_permission?: Array | undefined, pin_code_assignment?: Array | undefined, primary_account_numbers?: Array | undefined, monetary_account_id_fallback?: number | undefined, preferred_name_on_card?: string | undefined, second_line?: string | undefined, cancellation_reason?: string | undefined}; export type CompanyEmployeeCard = {pointer_counter_user: Pointer, pointer_monetary_account: Pointer, type: string, product_type: string, company_name_on_card?: string | undefined, employee_name_on_card?: string | undefined, employee_preferred_name_on_card?: string | undefined, amount_limit_monthly?: Amount | undefined, status?: string | undefined, card?: Card | undefined, amount_spent_monthly?: Amount | undefined, number_of_company_employee_card_receipt_pending?: number | undefined}; export type RelationUser = {user_id?: string | undefined, counter_user_id?: string | undefined, label_user?: LabelUser | undefined, counter_label_user?: LabelUser | undefined, relationship?: string | undefined, status?: string | undefined, user_status?: string | undefined, counter_user_status?: string | undefined, company_employee_setting_adyen_card_transaction?: CompanyEmployeeSettingAdyenCardTransaction | undefined, all_company_employee_card?: Array | undefined}; export type ShareInviteMonetaryAccountResponse = {status?: string | undefined, card_id?: number | undefined, id?: number | undefined, created?: string | undefined, updated?: string | undefined, counter_alias?: LabelMonetaryAccount | undefined, user_alias_cancelled?: LabelUser | undefined, monetary_account_id?: number | undefined, draft_share_invite_bank_id?: number | undefined, share_detail?: ShareDetail | undefined, access_type?: string | undefined, relation_user?: RelationUser | undefined, share_type?: string | undefined, start_date?: string | undefined, end_date?: string | undefined, description?: string | undefined}; export type UpdateApiUserUserIDShareInviteMonetaryAccountResponseItemIdArgs = {userID: 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: ShareInviteMonetaryAccountResponse}; export type UpdateApiUserUserIDShareInviteMonetaryAccountResponseItemIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const bunqId = z.object({id: z.number().int().optional()}); export const shareInviteMonetaryAccountResponseUpdate = 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}/share-invite-monetary-account-response/{itemId} */ export const updateApiUserUserIDShareInviteMonetaryAccountResponseItemId = async (args: UpdateApiUserUserIDShareInviteMonetaryAccountResponseItemIdArgs, options?: UpdateApiUserUserIDShareInviteMonetaryAccountResponseItemIdOptions) => { 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))}/share-invite-monetary-account-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(shareInviteMonetaryAccountResponseUpdate, await res.json()) };