export type GetApiSettingsTaxRatesExportArgs = {format?: ('csv' | 'xls' | 'xlsx') | undefined, identifier?: string | undefined, country?: string | undefined, state?: string | undefined, tax_rate_from?: number | undefined, tax_rate_to?: number | undefined}; export type GetApiSettingsTaxRatesExportOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export tax rates as csv, xls or xlsx * * GET /settings/tax-rates/export */ export const getApiSettingsTaxRatesExport = async (args: GetApiSettingsTaxRatesExportArgs, options?: GetApiSettingsTaxRatesExportOptions) => { const {baseUrl = "http://localhost:8000/api/admin", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.format != null) query.append("format", String(args.format)) if (args.identifier != null) query.append("identifier", String(args.identifier)) if (args.country != null) query.append("country", String(args.country)) if (args.state != null) query.append("state", String(args.state)) if (args.tax_rate_from != null) query.append("tax_rate_from", String(args.tax_rate_from)) if (args.tax_rate_to != null) query.append("tax_rate_to", String(args.tax_rate_to)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/settings/tax-rates/export${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() };