Class: AmazonPay::Response
- Inherits:
-
Object
- Object
- AmazonPay::Response
- Defined in:
- lib/amazon_pay/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.
6 7 8 |
# File 'lib/amazon_pay/response.rb', line 6 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
10 11 12 |
# File 'lib/amazon_pay/response.rb', line 10 def body @response.body end |
#code ⇒ Object
27 28 29 |
# File 'lib/amazon_pay/response.rb', line 27 def code @response.code end |
#get_element(xpath, xml_element) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/amazon_pay/response.rb', line 18 def get_element(xpath, xml_element) xml = to_xml value = nil xml.elements.each(xpath) do |element| value = element.elements[xml_element].text end value end |
#success ⇒ Object
31 32 33 |
# File 'lib/amazon_pay/response.rb', line 31 def success @response.code.eql? '200' end |
#to_xml ⇒ Object
14 15 16 |
# File 'lib/amazon_pay/response.rb', line 14 def to_xml REXML::Document.new(body) end |