export type GetApiV4ReportsLatestDownloadFormatArgs = {'Content-Type'?: string | undefined, format: string | null, having_any_tags?: string | undefined, having_all_tags?: string | undefined, exclude_having_any_tags?: string | undefined, exclude_having_all_tags?: string | undefined, order_by?: ('DATE_COMPLETED' | 'DATE_RUN' | 'NAME' | 'STATUS' | 'USER') | undefined, order?: ('ASCENDING' | 'DESCENDING') | undefined, offset?: string | undefined, limit?: string | undefined, filename?: string | undefined}; export type GetApiV4ReportsLatestDownloadFormatOptions = {baseUrl?: string | undefined, HEADER?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download the latest report * * GET /v4/reports/latest/download{format} * * Also accepts auth: QUERY, COOKIE */ export const getApiV4ReportsLatestDownloadFormat = async (args: GetApiV4ReportsLatestDownloadFormatArgs, options?: GetApiV4ReportsLatestDownloadFormatOptions) => { 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.having_any_tags != null) query.append("having_any_tags", String(args.having_any_tags)) if (args.having_all_tags != null) query.append("having_all_tags", String(args.having_all_tags)) if (args.exclude_having_any_tags != null) query.append("exclude_having_any_tags", String(args.exclude_having_any_tags)) if (args.exclude_having_all_tags != null) query.append("exclude_having_all_tags", String(args.exclude_having_all_tags)) if (args.order_by != null) query.append("order_by", String(args.order_by)) if (args.order != null) query.append("order", String(args.order)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.filename != null) query.append("filename", String(args.filename)) if (HEADER !== undefined) headers.set("Authorization", HEADER) const url = `${baseUrl.replace(/\/+$/, '')}/v4/reports/latest/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() };