export type GetApiApiUserEventsDownloadArgs = {page: number, status?: string | undefined, user?: string | undefined, leagues?: string | undefined}; export type GetApiApiUserEventsDownloadOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export user events * * GET /api/user/events/download */ export const getApiApiUserEventsDownload = async (args: GetApiApiUserEventsDownloadArgs, options: GetApiApiUserEventsDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.page != null) query.append("page", String(args.page)) if (args.status != null) query.append("status", String(args.status)) if (args.user != null) query.append("user", String(args.user)) if (args.leagues != null) query.append("leagues", String(args.leagues)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/user/events/download${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() };