export type GetApiReopenSeatsTripsArgs = {departure_date: string, departure_station_id?: number | undefined, arrival_station_id?: number | undefined}; export type GetApiReopenSeatsTripsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search trips * * GET /reopen_seats/trips */ export const getApiReopenSeatsTrips = async (args: GetApiReopenSeatsTripsArgs, options?: GetApiReopenSeatsTripsOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.departure_date != null) query.append("departure_date", String(args.departure_date)) 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)) const url = `${baseUrl.replace(/\/+$/, '')}/reopen_seats/trips${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 };