Class: PagseguroCatcher::Transaction::Base
- Inherits:
-
Body
- Object
- Body
- PagseguroCatcher::Transaction::Base
show all
- Defined in:
- lib/pagseguro_catcher/transaction/base.rb
Instance Attribute Summary
Attributes inherited from Body
#body
Instance Method Summary
collapse
Methods inherited from Body
#[], #method_missing
Constructor Details
#initialize(xml) ⇒ Base
Returns a new instance of Base.
7
8
9
10
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 7
def initialize(xml)
self.body = Hash.from_xml(xml)["transaction"]
self.body.recursive_symbolize_keys! if self.body
end
|
Instance Method Details
#date ⇒ Object
41
42
43
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 41
def date
self[:date].to_datetime.change(:offset => "-0300")
end
|
#each_item ⇒ Object
37
38
39
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 37
def each_item
self.items.each { |item| yield item }
end
|
#items ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 27
def items
@items = []
self[:items][:item].each do |item|
@items << PagseguroCatcher::Transaction::Item.new(item)
end
@items
end
|
#last_event_date ⇒ Object
45
46
47
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 45
def last_event_date
self[:lastEventDate].to_datetime.change(:offset => "-0300")
end
|
#payment_method_code ⇒ Object
61
62
63
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 61
def payment_method_code
PAYMENT_CODES[self[:paymentMethod][:code].to_i]
end
|
#payment_method_type ⇒ Object
57
58
59
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 57
def payment_method_type
PAYMENT_TYPES[self[:paymentMethod][:type].to_i]
end
|
#transaction_status ⇒ Object
53
54
55
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 53
def transaction_status
TRANSACTION_STATUS[self[:status].to_i]
end
|
#transaction_type ⇒ Object
49
50
51
|
# File 'lib/pagseguro_catcher/transaction/base.rb', line 49
def transaction_type
TRANSACTION_TYPES[self[:type].to_i]
end
|