Class: PayWithAmazon::Response

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

Overview

This class provides helpers to parse the response

Instance Method Summary collapse

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

#bodyObject



12
13
14
# File 'lib/pay_with_amazon/response.rb', line 12

def body
  @response.body
end

#codeObject



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

#successObject



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_xmlObject



16
17
18
# File 'lib/pay_with_amazon/response.rb', line 16

def to_xml
  REXML::Document.new(body)
end