export type GetApiApiV1SectoresStatsCsvArgs = {'If-None-Match'?: string | undefined}; export type GetApiApiV1SectoresStatsCsvOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Aggregates by CNAE sector (CSV) * * GET /api/v1/sectores/stats.csv */ export const getApiApiV1SectoresStatsCsv = async (args: GetApiApiV1SectoresStatsCsvArgs, options?: GetApiApiV1SectoresStatsCsvOptions) => { const {baseUrl = "https://openmercantil.es", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args['If-None-Match'] != null) headers.set("If-None-Match", String(args['If-None-Match'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/sectores/stats.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() };