export type GetApiReportsAccountSalesArgs = {start_date: string, end_date: string, counter_id?: number | undefined, departure_station_id?: number | undefined}; export type GetApiReportsAccountSalesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Account sales report * * GET /reports/account_sales */ export const getApiReportsAccountSales = async (args: GetApiReportsAccountSalesArgs, options?: GetApiReportsAccountSalesOptions) => { 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.counter_id != null) query.append("counter_id", String(args.counter_id)) if (args.departure_station_id != null) query.append("departure_station_id", String(args.departure_station_id)) const url = `${baseUrl.replace(/\/+$/, '')}/reports/account_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 };