export type GetApiV2PartitionPartitionIdReportUserCsvArgs = {month: number, partitionId: string, year: number}; export type GetApiV2PartitionPartitionIdReportUserCsvOptions = {baseUrl?: string | undefined, XAuthToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve user summary report in CSV format * * GET /v2/partition/{partitionId}/report/user/csv */ export const getApiV2PartitionPartitionIdReportUserCsv = async (args: GetApiV2PartitionPartitionIdReportUserCsvArgs, options?: GetApiV2PartitionPartitionIdReportUserCsvOptions) => { const {baseUrl = "https://api.alianza.com", fetch: fetchFn = fetch, XAuthToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.month != null) query.append("month", String(args.month)) if (args.year != null) query.append("year", String(args.year)) if (XAuthToken !== undefined) headers.set("X-AUTH-TOKEN", XAuthToken) const url = `${baseUrl.replace(/\/+$/, '')}/v2/partition/${encodeURIComponent(String(args.partitionId))}/report/user/csv${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() };