export type GetApiInvoicesInvoiceIdItemsCsvArgs = {invoiceId: string}; export type GetApiInvoicesInvoiceIdItemsCsvOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Invoice (CSV) * * GET /invoices/{invoiceId}/items.csv */ export const getApiInvoicesInvoiceIdItemsCsv = async (args: GetApiInvoicesInvoiceIdItemsCsvArgs, options?: GetApiInvoicesInvoiceIdItemsCsvOptions) => { const {baseUrl = "https://api.getredo.com/v2.2", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/invoices/${encodeURIComponent(String(args.invoiceId))}/items.csv${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.text() };