These docs are for v1.0. Click to read the latest docs for v2.0.

book

This method is used to book a new trip

book(tripBooking: TripBooking) : Call<TripInfo>

This method Iaccepts a TripBooking as a parameter. This can be created with a quoteId, UserInfo object and optional flightNumber.

QuoteService needs to be used in order to get a quoteId and UserService to get a UserInfo object.

Parameters

  • tripBooking: TripBooking

Returns

Call<TripInfo>

Errors

Examples

iOS

let tripService = Karhoo.getTripService()
let userInfo = UserInfo(userId: "123",
                        firstName: "John",
                        lastName: "Smith",
                        email: "[email protected]",
                        mobileNumber: "+441234567890",
                        locale: "uk",
                        metadata: "")
let tripBooking = TripBooking(quoteId: "1234",
                              userInfo: userInfo,
                              flightNumber: nil)

tripService.book(tripBooking: tripBooking).execute { result in
    switch result {
    case .success(let trip):
        print("Trip: \(trip)")
    case .failure(let error):
        print("error: \(error.code) \(error.message)")
    }
}

Android

val tripService = KarhooApi.tripService

val quoteId = "1234" // you can get this ID from the quotes service.
val passengers = Passengers(
                additionalPassengers = 0,
                passengerDetails = listOf(PassengerDetails(
                        firstName = "John",
                        lastName = "Smith",
                        phoneNumber = "+441234567890",
                        email = "[email protected]"
                )))
val flightNumber = "BOE747"

val tripBooking = TripBooking(
        quoteId = quoteId,
        passengers = passengers,
        flightNumber = flightNumber))

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