export type MetricRequest = {groupByProduct?: boolean | undefined, groupByTenant?: boolean | undefined, tenantLocators?: Array | undefined, products?: Array | undefined, tenantType?: ('test' | 'production' | 'retired' | 'deleted') | undefined, startTime: string, endTime: string, periodic?: ('none' | 'day' | 'week' | 'month' | 'quarter' | 'year') | undefined, currencies?: Array | undefined, localStartDateAdjusted: string, localEndDateAdjusted: string}; export type CreateApiBusinessStatsMetricsConversionRateDownloadArgs = {offset?: number | undefined, count?: number | undefined, backfillZeroes?: boolean | undefined, body: MetricRequest}; export type CreateApiBusinessStatsMetricsConversionRateDownloadOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /business-stats/metrics/conversionRate/download */ export const createApiBusinessStatsMetricsConversionRateDownload = async (args: CreateApiBusinessStatsMetricsConversionRateDownloadArgs, options: CreateApiBusinessStatsMetricsConversionRateDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/csv") if (args.offset != null) query.append("offset", String(args.offset)) if (args.count != null) query.append("count", String(args.count)) if (args.backfillZeroes != null) query.append("backfillZeroes", String(args.backfillZeroes)) const url = `${baseUrl.replace(/\/+$/, '')}/business-stats/metrics/conversionRate/download${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 res.text() };