export type GetApiApiUsersExportArgs = {active?: (0 | 1) | undefined, order_by?: string | undefined, order?: ('asc' | 'desc') | undefined}; export type GetApiApiUsersExportOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export users * * GET /api/users/export */ export const getApiApiUsersExport = async (args: GetApiApiUsersExportArgs, options: GetApiApiUsersExportOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.active != null) query.append("active", String(args.active)) if (args.order_by != null) query.append("order_by", String(args.order_by)) if (args.order != null) query.append("order", String(args.order)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/users/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 res.text() };