Class: Parsec::Request::Location

Inherits:
Base
  • Object
show all
Defined in:
lib/parsec/request/location.rb

Constant Summary

Constants inherited from Base

Base::DATE_FORMAT, Base::NAMESPACE, Base::RESOURCES

Instance Method Summary collapse

Methods inherited from Base

#client, #error, #initialize

Constructor Details

This class inherits a constructor from Parsec::Request::Base

Instance Method Details

#by_city(city_code) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/parsec/request/location.rb', line 6

def by_city(city_code)
  message = { read_request: { hotel_read_request: { request_type: 'GetLocations', city_code: city_code } } }
  response = client(:static_data).call('OTA_ReadRQ', message: message)

  Array.wrap(response.body.dig(:ota_read_rs, :read_response, :locations, :location)).map do |l|
    Parsec::Location.new(code: l[:@location_code], name: l[:location_name],
                         city_code: l[:city_code], country_iso: l[:country_iso])
  end
rescue Savon::Error => e
  Xlog.and_raise_error(e)
end