export type GetApiBusServicesArgs = {bus_id: number}; export type GetApiBusServicesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Return list of items. Permission: bus_service_maintenance * * GET /bus_services */ export const getApiBusServices = async (args: GetApiBusServicesArgs, options?: GetApiBusServicesOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.bus_id != null) query.append("bus_id", String(args.bus_id)) const url = `${baseUrl.replace(/\/+$/, '')}/bus_services${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 };