export type GetApiLogEventsArgs = {'pagination[limit]'?: number | undefined, 'pagination[page]'?: number | undefined, order_dir?: ('asc' | 'desc') | undefined, order_by?: string | undefined, start_date?: string | undefined, end_date?: string | undefined, start_time?: string | undefined, end_time?: string | undefined, user_id?: number | undefined, command?: string | undefined, item_id?: number | undefined, item_type?: string | undefined}; export type GetApiLogEventsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * User activity listing * * GET /log_events */ export const getApiLogEvents = async (args: GetApiLogEventsArgs, options?: GetApiLogEventsOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['pagination[limit]'] != null) query.append("pagination[limit]", String(args['pagination[limit]'])) if (args['pagination[page]'] != null) query.append("pagination[page]", String(args['pagination[page]'])) if (args.order_dir != null) query.append("order_dir", String(args.order_dir)) if (args.order_by != null) query.append("order_by", String(args.order_by)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (args.end_date != null) query.append("end_date", String(args.end_date)) if (args.start_time != null) query.append("start_time", String(args.start_time)) if (args.end_time != null) query.append("end_time", String(args.end_time)) if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args.command != null) query.append("command", String(args.command)) if (args.item_id != null) query.append("item_id", String(args.item_id)) if (args.item_type != null) query.append("item_type", String(args.item_type)) const url = `${baseUrl.replace(/\/+$/, '')}/log_events${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 };