export type GetApiV4ReportsReportIdDownloadFormatArgs = {'Content-Type'?: (string | null) | undefined, reportId: string, format: string | null, limit?: (string | null) | undefined, offset?: (string | null) | undefined, filename?: (string | null) | undefined}; export type GetApiV4ReportsReportIdDownloadFormatOptions = {baseUrl?: string | undefined, HEADER?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a report * * GET /v4/reports/{reportId}/download{format} * * Also accepts auth: QUERY, COOKIE */ export const getApiV4ReportsReportIdDownloadFormat = async (args: GetApiV4ReportsReportIdDownloadFormatArgs, options?: GetApiV4ReportsReportIdDownloadFormatOptions) => { const {baseUrl = "https://api.extole.io", fetch: fetchFn = fetch, HEADER} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.filename != null) query.append("filename", String(args.filename)) if (HEADER !== undefined) headers.set("Authorization", HEADER) const url = `${baseUrl.replace(/\/+$/, '')}/v4/reports/${encodeURIComponent(String(args.reportId))}/download${encodeURIComponent(String(args.format))}${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() };