export type GetApiV1BulkFinancialsCsvArgs = {sector?: (string | null) | undefined, fiscal_year?: (number | null) | undefined, fields?: (string | null) | undefined}; export type GetApiV1BulkFinancialsCsvOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export Financials Csv * * GET /v1/bulk/financials.csv */ export const getApiV1BulkFinancialsCsv = async (args: GetApiV1BulkFinancialsCsvArgs, options: GetApiV1BulkFinancialsCsvOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.sector != null) query.append("sector", String(args.sector)) if (args.fiscal_year != null) query.append("fiscal_year", String(args.fiscal_year)) if (args.fields != null) query.append("fields", String(args.fields)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/bulk/financials.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() };