export type GetApiV3CustomersIdInvoicesInvoiceIdPdfArgs = {id: string, invoiceId: string, type: string}; export type GetApiV3CustomersIdInvoicesInvoiceIdPdfOptions = {baseUrl?: string | undefined, customHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download invoice PDF * * GET /v3/customers/{id}/invoices/{invoiceId}/pdf */ export const getApiV3CustomersIdInvoicesInvoiceIdPdf = async (args: GetApiV3CustomersIdInvoicesInvoiceIdPdfArgs, options?: GetApiV3CustomersIdInvoicesInvoiceIdPdfOptions) => { const {baseUrl = "https://integrators.prod.api.tabsplatform.com", fetch: fetchFn = fetch, customHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.type != null) query.append("type", String(args.type)) if (customHeader !== undefined) headers.set("Authorization", customHeader) const url = `${baseUrl.replace(/\/+$/, '')}/v3/customers/${encodeURIComponent(String(args.id))}/invoices/${encodeURIComponent(String(args.invoiceId))}/pdf${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() };