Class: Amadeus::Namespaces::Booking::HotelBookings

Inherits:
Client::Decorator
  • Object
show all
Defined in:
lib/amadeus/namespaces/booking/hotel_bookings.rb

Overview

A namespaced client for the /v1/booking/hotel_bookings endpoints

Access via the Amadeus::Client object

amadeus = Amadeus::Client.new
amadeus.booking.hotel_bookings

Instance Method Summary collapse

Instance Method Details

#post(hotel_offer_id, guests, payments) ⇒ Amadeus:Response

Book a specific room

The parameters guests and payments can be passed as dictionary or list of dictionaries. If they are dictionary in this method they are converted to a list of dictionaries.

Examples:

book for a hotel offer

amadeus.booking.hotel_bookings.post(
   hotel_offer_id, guests, payments
 )

Parameters:

  • params (Hash)

    a customizable set of options

Returns:

  • (Amadeus:Response)

    a parsed response

Raises:

  • (Amadeus:Base)

    an exception if the call failed



29
30
31
32
33
# File 'lib/amadeus/namespaces/booking/hotel_bookings.rb', line 29

def post(hotel_offer_id, guests, payments)
  body = prepare_body(hotel_offer_id, guests, payments)

  client.post('/v1/booking/hotel-bookings', body.to_json)
end

#prepare_body(hotel_offer_id, guests, payments) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/amadeus/namespaces/booking/hotel_bookings.rb', line 35

def prepare_body(hotel_offer_id, guests, payments)
  guests_info = [], pay_info = []

  guests.is_a?(Array) ? guests_info.push(guests).flatten! : guests_info.push(guests)
  payments.is_a?(Array) ? pay_info.push(payments).flatten! : pay_info.push(payments)

  {
    'data' => {
      'offerId' => hotel_offer_id,
      'guests' => guests_info,
      'payments' => pay_info
    }
  }
end