export type GetApiInvoicesPendingItemsCsvOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Pending Invoice (CSV) * * GET /invoices/pending/items.csv */ export const getApiInvoicesPendingItemsCsv = async (options?: GetApiInvoicesPendingItemsCsvOptions) => { 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/pending/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() };