export type CreateApiHistoryTripsSearchArgs = {body: {'search[start_departure_date]'?: string | undefined, 'search[end_departure_date]'?: string | undefined, 'search[departure_days]'?: (Array<'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday'>) | undefined, 'search[is_cts]'?: boolean | undefined, 'search[status]'?: ('pending' | 'success' | 'fail' | 'rollback' | '') | undefined, 'search[trip][departure_time]'?: Array | undefined, 'search[trip_segments][departure_station_id]'?: number | undefined, 'search[trip_segments][arrival_station_id]'?: number | undefined, 'search[coach][id]'?: number | undefined, 'search[coach][seat_profile_id]'?: number | undefined, 'search[coach][counter_group_id]'?: number | undefined, 'pagination[limit]'?: number | undefined, 'pagination[page]'?: number | undefined}}; export type CreateApiHistoryTripsSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search by history of trips creation * * POST /history/trips/search */ export const createApiHistoryTripsSearch = async (args: CreateApiHistoryTripsSearchArgs, options?: CreateApiHistoryTripsSearchOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") const url = `${baseUrl.replace(/\/+$/, '')}/history/trips/search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };