Sha256: c544db303d6abfb24d437ee51abaddb79c9d64e3779bc6efb0821083be4aa736

Contents?: true

Size: 798 Bytes

Versions: 5

Compression:

Stored size: 798 Bytes

Contents

module PagSeguro
  class PaymentOrders < Base
    class Item < Hashie::Dash
      include Hashie::Extensions::Dash::PropertyTranslation
      include Hashie::Extensions::IgnoreUndeclared
      include Hashie::Extensions::IndifferentAccess

      property :amount, transform_with: ->(value) { format "R$%.2f", value }
      property :scheduling_date, from: :schedulingDate, transform_with: ->(value) { value.to_date }
      property :last_event_date, from: :lastEventDate, transform_with: ->(value) { value.to_date }
    end

    def fetch(code, params = {})
      params.reverse_merge! status: 5, page: 0
      response = api.get("/pre-approvals/#{code}/payment-orders", params)
      orders = response.body["paymentOrders"] || {}
      orders.values.map { |item| Item.new item }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pagseguro_next-0.4.0 lib/pagseguro/payment_orders.rb
pagseguro_next-0.3.0 lib/pagseguro/payment_orders.rb
pagseguro_next-0.2.0 lib/pagseguro/payment_orders.rb
pagseguro_next-0.1.1 lib/pagseguro/payment_orders.rb
pagseguro_next-0.1.0 lib/pagseguro/payment_orders.rb