export type GetApiAgentCommissionsArgs = {agent_id?: number | undefined}; export type GetApiAgentCommissionsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List * * GET /agent_commissions */ export const getApiAgentCommissions = async (args: GetApiAgentCommissionsArgs, options?: GetApiAgentCommissionsOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.agent_id != null) query.append("agent_id", String(args.agent_id)) const url = `${baseUrl.replace(/\/+$/, '')}/agent_commissions${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 };