export type GetApiReportsAgentSalesArgs = {start_date: string, end_date: string, agent_id?: number | undefined, departure_station_id?: number | undefined, date_type: 'transaction' | 'trip', report_type: 'detailed' | 'summary'}; export type GetApiReportsAgentSalesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Agent sales report * * GET /reports/agent_sales */ export const getApiReportsAgentSales = async (args: GetApiReportsAgentSalesArgs, options?: GetApiReportsAgentSalesOptions) => { 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.agent_id != null) query.append("agent_id", String(args.agent_id)) if (args.departure_station_id != null) query.append("departure_station_id", String(args.departure_station_id)) if (args.date_type != null) query.append("date_type", String(args.date_type)) if (args.report_type != null) query.append("report_type", String(args.report_type)) const url = `${baseUrl.replace(/\/+$/, '')}/reports/agent_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 };