export type BinBarcode = {orderBarcode?: boolean | undefined, singleUseBinBarcode?: boolean | undefined, packagingBarcode?: boolean | undefined}; export type GetApiBinsBarcodeSvgArgs = {barcode: BinBarcode}; export type GetApiBinsBarcodeSvgOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GET /bins/{barcode}.svg */ export const getApiBinsBarcodeSvg = async (args: GetApiBinsBarcodeSvgArgs, options: GetApiBinsBarcodeSvgOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/svg+xml") const url = `${baseUrl.replace(/\/+$/, '')}/bins/${encodeURIComponent(String(args.barcode))}.svg${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() };