Class: Parsec::Request::City

Inherits:
Base
  • Object
show all
Defined in:
lib/parsec/request/city.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/city.rb', line 6

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

  Array.wrap(response.body.dig(:ota_read_rs, :read_response, :cities, :city)).map do |c|
    Parsec::City.new(code: c[:@city_code], name: c[:city_name], country_iso: c[:country_iso])
  end
rescue Savon::Error => e
  Xlog.and_raise_error(e)
end