export type GetApiBillingInvoicesInvoiceIdDownloadArgs = {invoice_id: string, 'x-entity-id'?: string | undefined}; export type GetApiBillingInvoicesInvoiceIdDownloadOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download Invoice PDF * * GET /billing/invoices/{invoice_id}/download */ export const getApiBillingInvoicesInvoiceIdDownload = async (args: GetApiBillingInvoicesInvoiceIdDownloadArgs, options?: GetApiBillingInvoicesInvoiceIdDownloadOptions) => { const {baseUrl = "https://api.meow.com/v1", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args['x-entity-id'] != null) headers.set("x-entity-id", String(args['x-entity-id'])) if (apiKeyAuth !== undefined) headers.set("x-api-key", apiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/billing/invoices/${encodeURIComponent(String(args.invoice_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() };