export type GetApiV1ReportsContextsContextIdVarianceExportArgs = {'X-Request-Id'?: string | undefined, contextId: string, date_from: string, date_to: string, source_id?: string | undefined, format?: ('csv' | 'pdf') | undefined}; export type GetApiV1ReportsContextsContextIdVarianceExportOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export variance report * * GET /v1/reports/contexts/{contextId}/variance/export */ export const getApiV1ReportsContextsContextIdVarianceExport = async (args: GetApiV1ReportsContextsContextIdVarianceExportArgs, options?: GetApiV1ReportsContextsContextIdVarianceExportOptions) => { const {baseUrl = "https://identity.sandbox.lerian.net", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args['X-Request-Id'] != null) headers.set("X-Request-Id", String(args['X-Request-Id'])) if (args.date_from != null) query.append("date_from", String(args.date_from)) if (args.date_to != null) query.append("date_to", String(args.date_to)) if (args.source_id != null) query.append("source_id", String(args.source_id)) if (args.format != null) query.append("format", String(args.format)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/reports/contexts/${encodeURIComponent(String(args.contextId))}/variance/export${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() };