export type GetApiReportsDriverDutyArgs = {start_date: string, end_date: string, driver_id: number}; export type GetApiReportsDriverDutyOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Driver Duty Report * * GET /reports/driver_duty */ export const getApiReportsDriverDuty = async (args: GetApiReportsDriverDutyArgs, options?: GetApiReportsDriverDutyOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = 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 (args.driver_id != null) query.append("driver_id", String(args.driver_id)) const url = `${baseUrl.replace(/\/+$/, '')}/reports/driver_duty${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 };