export type GetApiReportsAgentTopupsArgs = {start_date: string, end_date: string, agent_id: number}; export type GetApiReportsAgentTopupsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Agent topup report * * GET /reports/agent_topups */ export const getApiReportsAgentTopups = async (args: GetApiReportsAgentTopupsArgs, options?: GetApiReportsAgentTopupsOptions) => { 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)) const url = `${baseUrl.replace(/\/+$/, '')}/reports/agent_topups${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 };