export type GetApiApiV1ContractsTopCompaniesCsvArgs = {limit?: number | undefined}; export type GetApiApiV1ContractsTopCompaniesCsvOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Corporate suppliers by award procedures (CSV) * * GET /api/v1/contracts/top-companies.csv */ export const getApiApiV1ContractsTopCompaniesCsv = async (args: GetApiApiV1ContractsTopCompaniesCsvArgs, options?: GetApiApiV1ContractsTopCompaniesCsvOptions) => { const {baseUrl = "https://openmercantil.es", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.limit != null) query.append("limit", String(args.limit)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/contracts/top-companies.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() };