export type CreateApiTripsChangeCoachArgs = {body: {trip_ids: number, coach_id: number, 'cts_routes[cts_user_id]': Array, 'cts_routes[cts_route_id]': Array, 'cts_routes[enabled]': Array, 'segments[departure_station_id]': Array, 'segments[arrival_station_id]': Array, 'segments[available_after_station_id]'?: Array | undefined, 'segments[blocked_seat_numbers]'?: Array | undefined, 'segments[prices][currency]': Array<'MYR' | 'SGD'>, 'segments[prices][normal_price]'?: Array | undefined, 'segments[prices][return_price]'?: Array | undefined, 'segments[prices][online_price]'?: Array | undefined, 'segments[prices][agent_price]'?: Array | undefined, 'segments[prices][spad_price]'?: Array | undefined, 'segments[lock_version]'?: number | undefined}}; export type CreateApiTripsChangeCoachOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Change coach. (Permission: trip_maintenance) * * POST /trips/change_coach */ export const createApiTripsChangeCoach = async (args: CreateApiTripsChangeCoachArgs, options?: CreateApiTripsChangeCoachOptions) => { 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(/\/+$/, '')}/trips/change_coach${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 };