Class: PayWithAmazon::Response
- Inherits:
-
Object
- Object
- PayWithAmazon::Response
- Defined in:
- lib/pay_with_amazon/response.rb
Overview
This class provides helpers to parse the response
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object
- #get_element(xpath, xml_element) ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #success ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
8 9 10 |
# File 'lib/pay_with_amazon/response.rb', line 8 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
12 13 14 |
# File 'lib/pay_with_amazon/response.rb', line 12 def body @response.body end |
#code ⇒ Object
28 29 30 |
# File 'lib/pay_with_amazon/response.rb', line 28 def code @response.code end |
#get_element(xpath, xml_element) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/pay_with_amazon/response.rb', line 20 def get_element(xpath, xml_element) xml = self.to_xml xml.elements.each(xpath) do |element| @value = element.elements[xml_element].text end return @value end |
#success ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/pay_with_amazon/response.rb', line 32 def success if @response.code.eql? '200' return true else return false end end |
#to_xml ⇒ Object
16 17 18 |
# File 'lib/pay_with_amazon/response.rb', line 16 def to_xml REXML::Document.new(body) end |