Class: AgentCooper::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_cooper/response.rb,
lib/agent_cooper/synchrony.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Response

Returns a new instance of Response.



4
5
6
# File 'lib/agent_cooper/response.rb', line 4

def initialize(attributes)
  @response = attributes.fetch(:response)
end

Instance Method Details

#bodyObject



9
10
11
# File 'lib/agent_cooper/response.rb', line 9

def body
  response.body
end

#codeObject



14
15
16
# File 'lib/agent_cooper/response.rb', line 14

def code
  response.code
end

#to_hash(options = {}) ⇒ Object



19
20
21
# File 'lib/agent_cooper/response.rb', line 19

def to_hash(options = {})
  xml.to_hash(options)
end

#valid?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/agent_cooper/response.rb', line 24

def valid?
  code == 200
end

#xmlObject



29
30
31
# File 'lib/agent_cooper/response.rb', line 29

def xml
  @xml ||= Nokogiri::XML(body)
end