export type GetApiApiV2PayeesPayeeUidImageArgs = {payeeUid: string}; export type GetApiApiV2PayeesPayeeUidImageOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Serves the image for the payee * * GET /api/v2/payees/{payeeUid}/image */ export const getApiApiV2PayeesPayeeUidImage = async (args: GetApiApiV2PayeesPayeeUidImageArgs, options: GetApiApiV2PayeesPayeeUidImageOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/payees/${encodeURIComponent(String(args.payeeUid))}/image${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 res.blob() };