Class: PagSeguro::SubscriptionPaymentOrder::ResponseSerializer
- Inherits:
-
Object
- Object
- PagSeguro::SubscriptionPaymentOrder::ResponseSerializer
- Defined in:
- lib/pagseguro/subscription_payment_order/response_serializer.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(xml) ⇒ ResponseSerializer
constructor
A new instance of ResponseSerializer.
- #serialize ⇒ Object
Constructor Details
#initialize(xml) ⇒ ResponseSerializer
Returns a new instance of ResponseSerializer.
6 7 8 |
# File 'lib/pagseguro/subscription_payment_order/response_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/subscription_payment_order/response_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/subscription_payment_order/response_serializer.rb', line 10 def serialize {}.tap do |data| data[:code] = xml.at_css('code').text data[:status] = SubscriptionPaymentOrder::STATUSES.key(xml.at_css('status').text.to_i) data[:amount] = to_amount xml.at_css('amount').text data[:gross_amount] = xml.at_css('grossAmount').text data[:scheduling_date] = Time.parse(xml.css('schedulingDate').text) data[:last_event_date] = Time.parse(xml.css('lastEventDate').text) data[:discount] = serialize_discount if xml.at_css('discount') data[:transactions] = serialize_transactions if xml.css('transactions').any? end end |