Class: Spreedly::Transaction
- Defined in:
- lib/spreedly/transactions/transaction.rb
Direct Known Subclasses
AddPaymentMethod, GatewayTransaction, RedactGateway, RedactPaymentMethod, RetainPaymentMethod
Class Method Summary collapse
Methods inherited from Model
Methods included from Fields
#field_hash, included, #initialize_fields
Constructor Details
This class inherits a constructor from Spreedly::Model
Class Method Details
.new_from(xml_doc) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/spreedly/transactions/transaction.rb', line 9 def self.new_from(xml_doc) case xml_doc.at_xpath('.//transaction_type').inner_text when 'AddPaymentMethod' return AddPaymentMethod.new(xml_doc) when 'Purchase' return Purchase.new(xml_doc) when 'Authorization' return Authorization.new(xml_doc) when 'Capture' return Capture.new(xml_doc) when 'Credit' return Refund.new(xml_doc) when 'Void' return Void.new(xml_doc) when 'RetainPaymentMethod' return RetainPaymentMethod.new(xml_doc) when 'RedactPaymentMethod' return RedactPaymentMethod.new(xml_doc) when 'RedactGateway' return RedactGateway.new(xml_doc) else Transaction.new(xml_doc) end end |
.new_list_from(xml_doc) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/spreedly/transactions/transaction.rb', line 34 def self.new_list_from(xml_doc) transactions = xml_doc.xpath('.//transactions/transaction') transactions.map do |each| self.new_from(each) end end |