Sha256: 82af8489992bb0661058b47233eaccde6c75ca1d1b9a9854d805302a126a2a3f

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

module PagarMe
  class BalanceOperation < PagarMeObject

    def method_missing(name, *args, &block)
      if @attributes['movement_object'] && @attributes['movement_object'].respond_to?(name)
        return movement_object.public_send(name, *args, &block)
      end

      super name, *args, &block
    end

    class << self
      def url(recipient_id = nil)
        if recipient_id
          "/recipients/#{recipient_id}/balance/operations"
        else
          '/balance/operations'
        end
      end

      def balance_operations(page = 1, count = 10)
        raise RequestError.new('Invalid page count') if page < 1 or count < 1

        params = { page: page, count: count }
        PagarMe::Request.get(url, params: params).call
      end

      def find_by_recipient_id(recipient_id, page = 1, count = 10)
        raise RequestError.new('Invalid ID') unless recipient_id.present?

        params = { page: page, count: count }
        PagarMe::Request.get(url(recipient_id), params: params).call
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pagarme-2.1.3 lib/pagarme/resources/balance_operation.rb
pagarme-2.1.2 lib/pagarme/resources/balance_operation.rb
pagarme-2.1.1 lib/pagarme/resources/balance_operation.rb
pagarme-2.1.0 lib/pagarme/resources/balance_operation.rb