export type GetApiReportRunsReportRunIdDownloadArgs = {report_run_id: string}; export type GetApiReportRunsReportRunIdDownloadOptions = {baseUrl?: string | undefined, secretKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Descargar el archivo de un reporte * * GET /report_runs/{report_run_id}/download */ export const getApiReportRunsReportRunIdDownload = async (args: GetApiReportRunsReportRunIdDownloadArgs, options?: GetApiReportRunsReportRunIdDownloadOptions) => { const {baseUrl = "https://app.recurrente.com/api", fetch: fetchFn = fetch, secretKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (secretKey !== undefined) headers.set("X-SECRET-KEY", secretKey) const url = `${baseUrl.replace(/\/+$/, '')}/report_runs/${encodeURIComponent(String(args.report_run_id))}/download${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.blob() };