Class: PagSeguro::TransactionRequest::RequestSerializer
- Inherits:
-
Object
- Object
- PagSeguro::TransactionRequest::RequestSerializer
- Defined in:
- lib/pagseguro/transaction_request/request_serializer.rb
Instance Attribute Summary collapse
-
#transaction_request ⇒ Object
readonly
The transaction request that will be serialized.
Instance Method Summary collapse
-
#initialize(transaction_request) ⇒ RequestSerializer
constructor
A new instance of RequestSerializer.
- #to_params ⇒ Object
- #to_xml_params ⇒ Object
Constructor Details
#initialize(transaction_request) ⇒ RequestSerializer
Returns a new instance of RequestSerializer.
7 8 9 |
# File 'lib/pagseguro/transaction_request/request_serializer.rb', line 7 def initialize(transaction_request) @transaction_request = transaction_request end |
Instance Attribute Details
#transaction_request ⇒ Object (readonly)
The transaction request that will be serialized.
5 6 7 |
# File 'lib/pagseguro/transaction_request/request_serializer.rb', line 5 def transaction_request @transaction_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 41 42 43 44 |
# File 'lib/pagseguro/transaction_request/request_serializer.rb', line 19 def to_params params[:receiverEmail] = PagSeguro.receiver_email params[:currency] = transaction_request.currency params[:reference] = transaction_request.reference params[:extraAmount] = to_amount(transaction_request.extra_amount) params[:notificationURL] = transaction_request.notification_url params[:paymentMethod] = transaction_request.payment_method params[:paymentMode] = transaction_request.payment_mode params[:creditCardToken] = transaction_request.credit_card_token if transaction_request.respond_to?(:credit_card_token) transaction_request.items.each.with_index(1) do |item, index| serialize_item(item, index) end serialize_sender(transaction_request.sender) serialize_shipping(transaction_request.shipping) serialize_extra_params(transaction_request.extra_params) serialize_bank(transaction_request.bank) if transaction_request.respond_to?(:bank) serialize_holder(transaction_request.holder) if transaction_request.respond_to?(:holder) serialize_billing_address(transaction_request.billing_address) if transaction_request.respond_to?(:billing_address) serialize_installment(transaction_request.installment) if transaction_request.respond_to?(:installment) params.delete_if {|key, value| value.nil? } params end |
#to_xml_params ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/pagseguro/transaction_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 |