export type GetApiApiV1InvoicesIdDownloadArgs = {id: string, t: string, variant?: 'preview' | undefined}; export type GetApiApiV1InvoicesIdDownloadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download the invoice file * * GET /api/v1/invoices/{id}/download */ export const getApiApiV1InvoicesIdDownload = async (args: GetApiApiV1InvoicesIdDownloadArgs, options?: GetApiApiV1InvoicesIdDownloadOptions) => { const {baseUrl = "https://scribo.causaprima.ai", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.t != null) query.append("t", String(args.t)) if (args.variant != null) query.append("variant", String(args.variant)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/invoices/${encodeURIComponent(String(args.id))}/download${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() };