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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PagarMeObject

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

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
11
12
# File 'lib/pagarme/resources/balance_operation.rb', line 4

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

  raise $!
end

Class Method Details

.balance_operations(*args, **params) ⇒ Object

Raises:



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

def balance_operations(*args, **params)
  params = PagarMe::Model.extract_page_count_or_params(*args, **params)
  raise RequestError.new('Invalid page count') if params[:page] < 1 or params[:count] < 1

  PagarMe::Request.get(url, params: params).call
end

.find_by_recipient_id(recipient_id, *args, **params) ⇒ Object

Raises:



30
31
32
33
34
35
36
# File 'lib/pagarme/resources/balance_operation.rb', line 30

def find_by_recipient_id(recipient_id, *args, **params)
  params = PagarMe::Model.extract_page_count_or_params(*args, **params)
  raise RequestError.new('Invalid page count') if params[:page] < 1 or params[:count] < 1
  raise RequestError.new('Invalid ID')         unless recipient_id.present?

  PagarMe::Request.get(url(recipient_id), params: params).call
end

.url(recipient_id = nil) ⇒ Object



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

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