export type InvoiceId = unknown; export type GetApiApiV1InvoicesInvoiceIdXmlArgs = {invoice_id: InvoiceId}; export type GetApiApiV1InvoicesInvoiceIdXmlOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download invoice e-invoice XML * * GET /api/v1/invoices/{invoice_id}/xml */ export const getApiApiV1InvoicesInvoiceIdXml = async (args: GetApiApiV1InvoicesInvoiceIdXmlArgs, options: GetApiApiV1InvoicesInvoiceIdXmlOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/xml") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/invoices/${encodeURIComponent(String(args.invoice_id))}/xml${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() };