export type GetApiReportsTripSalesArgs = {start_departure_date: string, end_departure_date: string, departure_station_id?: number | undefined, arrival_station_id?: number | undefined}; export type GetApiReportsTripSalesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Trip list * * GET /reports/trip_sales */ export const getApiReportsTripSales = async (args: GetApiReportsTripSalesArgs, options?: GetApiReportsTripSalesOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.start_departure_date != null) query.append("start_departure_date", String(args.start_departure_date)) if (args.end_departure_date != null) query.append("end_departure_date", String(args.end_departure_date)) if (args.departure_station_id != null) query.append("departure_station_id", String(args.departure_station_id)) if (args.arrival_station_id != null) query.append("arrival_station_id", String(args.arrival_station_id)) const url = `${baseUrl.replace(/\/+$/, '')}/reports/trip_sales${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 };