export type GetApiV1ExportsMeasurementsArgs = {customerId: string, from?: string | undefined, to?: string | undefined, format?: 'csv' | undefined}; export type GetApiV1ExportsMeasurementsOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v1/exports/measurements */ export const getApiV1ExportsMeasurements = async (args: GetApiV1ExportsMeasurementsArgs, options: GetApiV1ExportsMeasurementsOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.customerId != null) query.append("customerId", String(args.customerId)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.format != null) query.append("format", String(args.format)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/exports/measurements${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 undefined };