Class: PagSeguro::Transaction::Serializer
- Inherits:
-
Object
- Object
- PagSeguro::Transaction::Serializer
- Defined in:
- lib/pagseguro/transaction/serializer.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(xml) ⇒ Serializer
constructor
A new instance of Serializer.
- #serialize ⇒ Object
- #serialize_status_history ⇒ Object
Constructor Details
#initialize(xml) ⇒ Serializer
Returns a new instance of Serializer.
6 7 8 |
# File 'lib/pagseguro/transaction/serializer.rb', line 6 def initialize(xml) @xml = xml end |
Instance Attribute Details
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
4 5 6 |
# File 'lib/pagseguro/transaction/serializer.rb', line 4 def xml @xml end |
Instance Method Details
#serialize ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pagseguro/transaction/serializer.rb', line 10 def serialize {}.tap do |data| serialize_general(data) serialize_amounts(data) serialize_dates(data) serialize_creditor(data) serialize_payments(data) serialize_items(data) serialize_sender(data) serialize_shipping(data) if xml.css("shipping").any? end end |
#serialize_status_history ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/pagseguro/transaction/serializer.rb', line 23 def serialize_status_history xml.css("status").map do |node| PagSeguro::TransactionStatus.new( code: node.css("code").text, date: Time.parse(node.css("date").text), notification_code: node.css("notificationCode").text ) end end |