export type GetApiAdminRewardExportSpaceIdArgs = {spaceId: string, createdTimeFrom?: string | undefined, createdTimeTo?: string | undefined}; export type GetApiAdminRewardExportSpaceIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export admin reward list as CSV * * GET /admin/reward/export/{spaceId} */ export const getApiAdminRewardExportSpaceId = async (args: GetApiAdminRewardExportSpaceIdArgs, options?: GetApiAdminRewardExportSpaceIdOptions) => { const {baseUrl = "https://app.teable.ai/api", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.createdTimeFrom != null) query.append("createdTimeFrom", String(args.createdTimeFrom)) if (args.createdTimeTo != null) query.append("createdTimeTo", String(args.createdTimeTo)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/admin/reward/export/${encodeURIComponent(String(args.spaceId))}${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() };