export type GetApiApiV1ExportCompaniesArgs = {provincia?: string | undefined, tipo?: string | undefined, año?: string | undefined, limit?: number | undefined, offset?: number | undefined, formato?: ('csv' | 'json') | undefined}; export type GetApiApiV1ExportCompaniesOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Request an offline company export artifact (currently unavailable) * * GET /api/v1/export/companies */ export const getApiApiV1ExportCompanies = async (args: GetApiApiV1ExportCompaniesArgs, options?: GetApiApiV1ExportCompaniesOptions) => { const {baseUrl = "https://openmercantil.es", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.provincia != null) query.append("provincia", String(args.provincia)) if (args.tipo != null) query.append("tipo", String(args.tipo)) if (args.año != null) query.append("año", String(args.año)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.formato != null) query.append("formato", String(args.formato)) if (apiKey !== undefined) headers.set("X-API-Key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/export/companies${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 undefined };