Class: Spreedly::Transaction

Inherits:
Model
  • Object
show all
Defined in:
lib/spreedly/transactions/transaction.rb

Class Method Summary collapse

Methods inherited from Model

#initialize

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
33
34
35
36
37
38
39
40
41
42
# 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 'OffsitePurchase'
    return OffsitePurchase.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 'Verification'
    return Verification.new(xml_doc)
  when 'RetainPaymentMethod'
    return RetainPaymentMethod.new(xml_doc)
  when 'RedactPaymentMethod'
    return RedactPaymentMethod.new(xml_doc)
  when 'RedactGateway'
    return RedactGateway.new(xml_doc)
  when 'RecacheSensitiveData'
    return RecacheSensitiveData.new(xml_doc)
  when 'DeliverPaymentMethod'
    return DeliverPaymentMethod.new(xml_doc)
  when 'Store'
    return Store.new(xml_doc)
  else
    Transaction.new(xml_doc)
  end
end

.new_list_from(xml_doc) ⇒ Object


44
45
46
47
48
49
# File 'lib/spreedly/transactions/transaction.rb', line 44

def self.new_list_from(xml_doc)
  transactions = xml_doc.xpath('.//transactions/transaction')
  transactions.map do |each|
    self.new_from(each)
  end
end