import {z} from 'zod' export type GetApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseRequestResponseIDNoteAttachmentArgs = {userID: number, 'monetary-accountID': number, 'request-responseID': 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}; export type GetApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseRequestResponseIDNoteAttachmentOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const image = z.object({attachment_public_uuid: z.string().optional(), content_type: z.string().optional(), height: z.number().int().optional(), width: z.number().int().optional()}); export const avatar = z.object({uuid: z.string().optional(), anchor_uuid: z.string().optional(), image: z.array(image).optional(), style: z.string().optional()}); export const labelUser = z.object({uuid: z.string().optional(), display_name: z.string().optional(), country: z.string().optional(), avatar: avatar.optional(), public_nick_name: z.string().optional()}); export const attachmentMonetaryAccountPayment = z.object({id: z.number().int().optional(), monetary_account_id: z.number().int().optional()}); export const noteAttachmentRequestResponseListing = z.object({id: z.number().int().optional(), created: z.string().optional(), updated: z.string().optional(), label_user_creator: labelUser.optional(), description: z.string().optional(), attachment: z.array(attachmentMonetaryAccountPayment).optional()}); export const getApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseRequestResponseIDNoteAttachmentResponse = z.array(noteAttachmentRequestResponseListing); 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 }; /** * GET /user/{userID}/monetary-account/{monetary-accountID}/request-response/{request-responseID}/note-attachment */ export const getApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseRequestResponseIDNoteAttachment = async (args: GetApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseRequestResponseIDNoteAttachmentArgs, options?: GetApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseRequestResponseIDNoteAttachmentOptions) => { const {baseUrl = "https://public-api.sandbox.bunq.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() 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['request-responseID']))}/note-attachment${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiUserUserIDMonetaryAccountMonetaryAccountIDRequestResponseRequestResponseIDNoteAttachmentResponse, await res.json()) };