Method: Parsec::Request::Order#list

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

#list(from_date, to_date, hotel_code = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/parsec/request/order.rb', line 6

def list(from_date, to_date, hotel_code = nil)
  attributes = { xmlns: NAMESPACE }
  booking_search = {
    date_range: {
      '@Start' => from_date.strftime(DATE_FORMAT),
      '@End' => to_date.strftime(DATE_FORMAT),
      '@DateType' => 'Arrival'
    }
  }
  booking_search[:hotel_ref] = { '@HotelCode' => hotel_code } if hotel_code.present?
  response = client(:list).call('OTA_BookingListRQ', attributes: attributes, message: { booking_search: booking_search })
  return error(response.body[:ota_booking_list_rs]) if response.body[:ota_booking_list_rs][:errors].present?

  response.body[:ota_booking_list_rs]
end