Class: HotelBeds::Action::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/hotel_beds/action/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, response) ⇒ Response

Returns a new instance of Response.



10
11
12
13
14
15
16
# File 'lib/hotel_beds/action/response.rb', line 10

def initialize(request, response)
  self.request = request
  self.headers = response.header
  self.body = Nokogiri::XML(response.body.values.first)
  self.errors = HotelBeds::Parser::Errors.new(response).to_model(self)
  freeze
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



7
8
9
# File 'lib/hotel_beds/action/response.rb', line 7

def body
  @body
end

#errorsObject

Returns the value of attribute errors.



7
8
9
# File 'lib/hotel_beds/action/response.rb', line 7

def errors
  @errors
end

#headersObject

Returns the value of attribute headers.



7
8
9
# File 'lib/hotel_beds/action/response.rb', line 7

def headers
  @headers
end

#requestObject

Returns the value of attribute request.



7
8
9
# File 'lib/hotel_beds/action/response.rb', line 7

def request
  @request
end

Instance Method Details

#inspectObject



18
19
20
# File 'lib/hotel_beds/action/response.rb', line 18

def inspect
  "<#{self.class.name} errors=#{errors.inspect} headers=#{headers.inspect} body=#{body.to_s}>"
end

#success?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/hotel_beds/action/response.rb', line 22

def success?
  errors.empty?
end