Class: Parsec::Request::Region

Inherits:
Base
  • Object
show all
Defined in:
lib/parsec/request/region.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_country(country_iso_code) ⇒ Object



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

def by_country(country_iso_code)
  message = { read_request: { hotel_read_request: { request_type: 'GetRegions', country_code: country_iso_code } } }
  response = client(:static_data).call('OTA_ReadRQ', message: message)

  Array.wrap(response.body.dig(:ota_read_rs, :read_response, :regions, :region)).map do |r|
    Parsec::Region.new(code: r[:@region_code], name: r[:region_name], country_iso: r[:country_iso])
  end
rescue Savon::Error => e
  Xlog.and_raise_error(e)
end