export type GetApiUserActionsArgs = {page?: number | undefined, limit?: number | undefined, wallet?: string | undefined, actions?: Array | undefined, withdrawalType?: number | undefined, assets?: Array | undefined, assetSymbols?: Array | undefined, startTimestamp?: number | undefined, endTimestamp?: number | undefined, status?: number | undefined}; export type GetApiUserActionsOptions = {baseUrl: string, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * List user actions (paginated, admin) * * GET /user-actions */ export const getApiUserActions = async (args: GetApiUserActionsArgs, options: GetApiUserActionsOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.wallet != null) query.append("wallet", String(args.wallet)) for (const item of args.actions ?? []) query.append("actions", String(item)) if (args.withdrawalType != null) query.append("withdrawalType", String(args.withdrawalType)) for (const item of args.assets ?? []) query.append("assets", String(item)) for (const item of args.assetSymbols ?? []) query.append("assetSymbols", String(item)) if (args.startTimestamp != null) query.append("startTimestamp", String(args.startTimestamp)) if (args.endTimestamp != null) query.append("endTimestamp", String(args.endTimestamp)) if (args.status != null) query.append("status", String(args.status)) if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/user-actions${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 };