Class: PagarMe::BalanceOperation

Inherits:
PagarMeObject show all
Defined in:
lib/pagarme/resources/balance_operation.rb

Constant Summary

Constants inherited from PagarMeObject

PagarMeObject::RESOURCES

Instance Attribute Summary

Attributes inherited from PagarMeObject

#attributes, #unsaved_attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PagarMeObject

#==, #[]=, convert, #empty?, #initialize, #respond_to?, #to_hash, #to_s

Constructor Details

This class inherits a constructor from PagarMe::PagarMeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/pagarme/resources/balance_operation.rb', line 4

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 Method Details

.balance_operations(page = 1, count = 10) ⇒ Object

Raises:



21
22
23
24
25
26
# File 'lib/pagarme/resources/balance_operation.rb', line 21

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

.find_by_recipient_id(recipient_id, page = 1, count = 10) ⇒ Object

Raises:



28
29
30
31
32
33
# File 'lib/pagarme/resources/balance_operation.rb', line 28

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

.url(recipient_id = nil) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/pagarme/resources/balance_operation.rb', line 13

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