export type GetApiV1ActivitiesArgs = {page?: number | undefined, limit?: number | undefined, search?: string | undefined, user_id?: number | undefined, following?: boolean | undefined, goal_counted?: boolean | undefined, start_date?: string | undefined, end_date?: string | undefined}; export type GetApiV1ActivitiesOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List activities * * GET /v1/activities */ export const getApiV1Activities = async (args: GetApiV1ActivitiesArgs, options?: GetApiV1ActivitiesOptions) => { const {baseUrl = "http://localhost:3000", fetch: fetchFn = fetch, BearerAuth} = 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.search != null) query.append("search", String(args.search)) if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args.following != null) query.append("following", String(args.following)) if (args.goal_counted != null) query.append("goal_counted", String(args.goal_counted)) 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 (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/activities${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 };