Class: Spreedly::GatewayTransaction
- Inherits:
-
Transaction
- Object
- Model
- Transaction
- Spreedly::GatewayTransaction
- Defined in:
- lib/spreedly/transactions/gateway_transaction.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#gateway_specific_fields ⇒ Object
readonly
Returns the value of attribute gateway_specific_fields.
-
#gateway_specific_response_fields ⇒ Object
readonly
Returns the value of attribute gateway_specific_response_fields.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#shipping_address ⇒ Object
readonly
Returns the value of attribute shipping_address.
Instance Method Summary collapse
-
#initialize(xml_doc) ⇒ GatewayTransaction
constructor
A new instance of GatewayTransaction.
- #parse_gateway_fields(xml_doc, path) ⇒ Object
Methods inherited from Transaction
Methods included from Fields
#field_hash, included, #initialize_fields
Constructor Details
#initialize(xml_doc) ⇒ GatewayTransaction
Returns a new instance of GatewayTransaction.
9 10 11 12 13 14 15 16 17 |
# File 'lib/spreedly/transactions/gateway_transaction.rb', line 9 def initialize(xml_doc) super response_xml_doc = xml_doc.at_xpath('.//response') shipping_address_xml_doc = xml_doc.at_xpath('.//shipping_address') @response = response_xml_doc ? Response.new(response_xml_doc) : nil @shipping_address = shipping_address_xml_doc ? ShippingAddress.new(shipping_address_xml_doc) : nil @gateway_specific_fields = parse_gateway_fields(xml_doc, './/gateway_specific_fields') @gateway_specific_response_fields = parse_gateway_fields(xml_doc, './/gateway_specific_response_fields') end |
Instance Attribute Details
#gateway_specific_fields ⇒ Object (readonly)
Returns the value of attribute gateway_specific_fields.
7 8 9 |
# File 'lib/spreedly/transactions/gateway_transaction.rb', line 7 def gateway_specific_fields @gateway_specific_fields end |
#gateway_specific_response_fields ⇒ Object (readonly)
Returns the value of attribute gateway_specific_response_fields.
7 8 9 |
# File 'lib/spreedly/transactions/gateway_transaction.rb', line 7 def gateway_specific_response_fields @gateway_specific_response_fields end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/spreedly/transactions/gateway_transaction.rb', line 7 def response @response end |
#shipping_address ⇒ Object (readonly)
Returns the value of attribute shipping_address.
7 8 9 |
# File 'lib/spreedly/transactions/gateway_transaction.rb', line 7 def shipping_address @shipping_address end |
Instance Method Details
#parse_gateway_fields(xml_doc, path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/spreedly/transactions/gateway_transaction.rb', line 19 def parse_gateway_fields(xml_doc, path) result = {} xml_doc.at_xpath(path).xpath('*').each do |node| node_name = node.name.to_sym if (node.elements.empty?) result[node_name] = node.text else node.elements.each do |childnode| result[node_name] ||= {} result[node_name][childnode.name.to_sym] = childnode.text end end end result end |