cancel

This method is used to cancel a trip.

cancel(tripCancellation: TripCancellation) : Call<Void>

This method is used to cancel a trip. To create the TripCancellation parameter, you need to know the tripIdentifier and cancelReason: CancelReason). It returns either success (void) or a KarhooError.
In case of you are using AuthenticationMethod.Guest, you need to use the followCode as the trip identifier, otherwise, you need to use tripId

Parameters

  • tripBooking: TripCancellation)

Returns

  • Call<Void>

Errors

Examples

iOS

let tripService = Karhoo.getTripService()
let tripCancellation = TripCancellation(tripId: "123", cancelReason: .notNeededAnymore)

tripService.cancel(tripCancellation: tripCancellation).execute { result in
    switch result {
    case .success:
        print("Trip cancelled")
    case .failure(let error):
        print("error: \(error.code) \(error.message)")
    }
}

Android

val tripService = KarhooApi.tripService

val tripCancellation = TripCancellation(
                          tripIdentifier = trip.tripId,
                          reason = CancellationReason.OTHER_USER_REASON)

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