search

Find information across current, past and future trips for a user.

placeSearch(placeSearch: PlaceSearch) : Call<Places>

By using the trip search endpoint you can get a list of trips matching the TripSearch

Parameters

  • tripSearch: TripSearch

Returns

Call<TripInfo>

Errors

Examples

iOS

let tripService = Karhoo.getTripService()
let tripSearch = TripSearch(tripStates: [.requested, .confirmed, .driverEnRoute],
                            tripType: .both)
                            
tripService.search(tripSearch: tripSearch).execute { result in
    switch result {
    case .success(let trips):
        print("Trips: \(trips)")
    case .failure(let error):
        print("error: \(error.code) \(error.message)")
    }
}

Android

val VALID_PAST_STATES = arrayOf(TripStatus.COMPLETED,
        TripStatus.NO_DRIVERS,
        TripStatus.CANCELLED_BY_USER,
        TripStatus.CANCELLED_BY_DISPATCH,
        TripStatus.CANCELLED_BY_KARHOO)

val tripSearch = TripSearch(tripType = "BOTH",
                      tripState = VALID_PAST_STATES.toList())

tripsService.search().execute { result ->
    when (result) {
        is Resource.Success -> print(result.data) //Handle data
        is Resource.Failure -> print(result.error)) //Handle error
    }
}