Class: Trebbianno::Response
- Inherits:
-
Object
- Object
- Trebbianno::Response
- Defined in:
- lib/trebbianno/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(raw_response, type) ⇒ Response
constructor
A new instance of Response.
- #parse_response(xml_response) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(raw_response, type) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 |
# File 'lib/trebbianno/response.rb', line 6 def initialize(raw_response, type) @raw_response = raw_response @response = parse_response(raw_response) @type = type end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/trebbianno/response.rb', line 4 def response @response end |
Instance Method Details
#failure? ⇒ Boolean
12 13 14 |
# File 'lib/trebbianno/response.rb', line 12 def failure? !success? end |
#parse_response(xml_response) ⇒ Object
21 22 23 24 25 |
# File 'lib/trebbianno/response.rb', line 21 def parse_response(xml_response) blank = xml_response.respond_to?(:empty?) ? !!xml_response.empty? : !xml_response return nil if blank XmlSimple.xml_in(xml_response) end |
#success? ⇒ Boolean
16 17 18 19 |
# File 'lib/trebbianno/response.rb', line 16 def success? # @response.parsed["#{@type}_response"]["#{@type}_result"][:status] == '0001' true end |