export type GetApiTripsSearchTicketingArgs = {departure_station_id: number, arrival_station_id: number, departure_date: string, return_date?: string | undefined, direct_return?: boolean | undefined}; export type GetApiTripsSearchTicketingOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search trips for Ticketing. No permission. Need role: agent OR staff. * * GET /trips/search_ticketing */ export const getApiTripsSearchTicketing = async (args: GetApiTripsSearchTicketingArgs, options?: GetApiTripsSearchTicketingOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.departure_station_id != null) query.append("departure_station_id", String(args.departure_station_id)) if (args.arrival_station_id != null) query.append("arrival_station_id", String(args.arrival_station_id)) if (args.departure_date != null) query.append("departure_date", String(args.departure_date)) if (args.return_date != null) query.append("return_date", String(args.return_date)) if (args.direct_return != null) query.append("direct_return", String(args.direct_return)) const url = `${baseUrl.replace(/\/+$/, '')}/trips/search_ticketing${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 };