export type FormatType = 'XML' | 'CSV' | 'IMAGE' | 'PDF' | 'EXCEL' | 'WORD' | 'HTML' | 'MHTML'; export type IntervalType = 'Minute' | 'Hour' | 'Day' | 'Month'; export type ReportExportPostBody = {report_id: string | null, format?: FormatType | undefined, activity_type?: (string | null) | undefined, interval_type?: IntervalType | undefined, start_date?: (string | null) | undefined, end_date?: (string | null) | undefined, start_time?: (string | null) | undefined, end_time?: (string | null) | undefined, device_id?: (Array | null) | undefined, user_id?: (Array | null) | undefined, media_id?: (Array | null) | undefined}; export type CreateApiReportExportArgs = {exclude_body?: boolean | undefined, body: ReportExportPostBody}; export type CreateApiReportExportOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate and export a report. * * POST /report/export * * Also accepts auth: ApiKeyInHeader, ApiKeyInQuery */ export const createApiReportExport = async (args: CreateApiReportExportArgs, options?: CreateApiReportExportOptions) => { const {baseUrl = "https://api.reveldigital.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.exclude_body != null) query.append("exclude_body", String(args.exclude_body)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/report/export${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };