Class: PagSeguro::PaymentRequest::RequestSerializer
- Inherits:
-
Object
- Object
- PagSeguro::PaymentRequest::RequestSerializer
- Defined in:
- lib/pagseguro/payment_request/request_serializer.rb
Instance Attribute Summary collapse
-
#payment_request ⇒ Object
readonly
The payment request that will be serialized.
Instance Method Summary collapse
-
#initialize(payment_request) ⇒ RequestSerializer
constructor
A new instance of RequestSerializer.
- #to_params ⇒ Object
- #to_xml_params ⇒ Object
Constructor Details
#initialize(payment_request) ⇒ RequestSerializer
Returns a new instance of RequestSerializer.
7 8 9 |
# File 'lib/pagseguro/payment_request/request_serializer.rb', line 7 def initialize(payment_request) @payment_request = payment_request end |
Instance Attribute Details
#payment_request ⇒ Object (readonly)
The payment request that will be serialized.
5 6 7 |
# File 'lib/pagseguro/payment_request/request_serializer.rb', line 5 def payment_request @payment_request end |
Instance Method Details
#to_params ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pagseguro/payment_request/request_serializer.rb', line 19 def to_params {}.tap do |data| data[:receiverEmail] = PagSeguro.receiver_email data[:currency] = payment_request.currency data[:reference] = payment_request.reference data[:extraAmount] = to_amount(payment_request.extra_amount) data[:redirectURL] = payment_request.redirect_url data[:notificationURL] = payment_request.notification_url data[:abandonURL] = payment_request.abandon_url data[:maxUses] = payment_request.max_uses data[:maxAge] = payment_request.max_age data[:credentials] = payment_request.credentials payment_request.items.each_with_index do |item, index| serialize_item(data, item, index.succ) end serialize_sender(data, payment_request.sender) serialize_shipping(data, payment_request.shipping) serialize_receivers(data, payment_request.receivers) serialize_extra_params(data, payment_request.extra_params) end.delete_if { |_, value| value.nil? } end |
#to_xml_params ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/pagseguro/payment_request/request_serializer.rb', line 11 def to_xml_params xml_builder.to_xml( save_with: Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS | Nokogiri::XML::Node::SaveOptions::FORMAT ) end |