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