export type GetApiApiTrackOrganizationStatsExportArgs = {startDate: string, endDate: string}; export type GetApiApiTrackOrganizationStatsExportOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export all organization statistics * * GET /api/track/organization/stats/export */ export const getApiApiTrackOrganizationStatsExport = async (args: GetApiApiTrackOrganizationStatsExportArgs, options: GetApiApiTrackOrganizationStatsExportOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.startDate != null) query.append("startDate", String(args.startDate)) if (args.endDate != null) query.append("endDate", String(args.endDate)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/track/organization/stats/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 undefined };