Class: Parsec::Request::Base

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

Direct Known Subclasses

Availability, City, Country, Hotel, Location, Order, Region

Constant Summary collapse

RESOURCES =
{
  static_data: 'staticdata/OTA2014A',
  hotel_info: 'hotelinfo/OTA2014A',
  availability: 'hotelavail/OTA2014Compact',
  reservation: 'hotelres/OTA2014Compact',
  list: 'bookinglist/OTA2014Compact',
  read: 'reservationsread/OTA2014Compact',
  cancel: 'hotelcancel/OTA2014Compact'
}.freeze
NAMESPACE =
'http://parsec.es/hotelapi/OTA2014Compact'
DATE_FORMAT =
'%Y-%m-%d'

Instance Method Summary collapse

Constructor Details

#initialize(integration = nil) ⇒ Base

Returns a new instance of Base.



22
23
24
# File 'lib/parsec/request/base.rb', line 22

def initialize(integration = nil)
  @integration = integration
end

Instance Method Details

#client(endpoint) ⇒ Object



26
27
28
29
30
31
# File 'lib/parsec/request/base.rb', line 26

def client(endpoint)
  Savon.client endpoint: "#{ParsecClient.configuration.host}/NewAvailabilityServlet/#{RESOURCES[endpoint]}",
               namespace: NAMESPACE,
               convert_request_keys_to: :camelcase,
               soap_header: security_tag
end

#error(response) ⇒ Object



33
34
35
# File 'lib/parsec/request/base.rb', line 33

def error(response)
  { error: response[:errors][:error] }
end