export type GetApiV1GetWorkoutHoursArgs = {start_date: string, end_date: string}; export type GetApiV1GetWorkoutHoursOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get workout hours in date range * * GET /v1/get_workout_hours */ export const getApiV1GetWorkoutHours = async (args: GetApiV1GetWorkoutHoursArgs, options?: GetApiV1GetWorkoutHoursOptions) => { const {baseUrl = "http://localhost:3000", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() 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/get_workout_hours${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 };