Method: Parsec::Request::Order#create

Defined in:
lib/parsec/request/order.rb

#create(booking_data, client_id, customer_text = nil) ⇒ Object

booking_data = [{ booking_code1:, adults1:, children1: }, { booking_code2:, adults2:, children2: }, …]



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/parsec/request/order.rb', line 31

def create(booking_data, client_id, customer_text = nil)
  message = {
    unique_i_d: { '@Type' => 'ClientReference', '@ID' => client_id },
    hotel_res: { rooms: { room: rooms_with_guests(booking_data, client_id) } }
  }
  message[:hotel_res][:special_requests] = { text: customer_text } if customer_text.present?
  response = booking_request('Booking', message)
  return error(response[:ota_booking_info_rs]) if response[:ota_booking_info_rs][:errors].present?

  Parsec::Order.build(response[:ota_booking_info_rs])
end