Class: PagarMe::Recipient

Inherits:
Model show all
Defined in:
lib/pagarme/resources/recipient.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 Model

all, class_name, #create, create, extract_page_count_or_params, find_by, find_by_id, #save, underscored_class_name, url, #url

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 in the class PagarMe::PagarMeObject

Class Method Details

.defaultObject



29
30
31
# File 'lib/pagarme/resources/recipient.rb', line 29

def self.default
  Company.default_recipient
end

Instance Method Details

#balanceObject



17
18
19
# File 'lib/pagarme/resources/recipient.rb', line 17

def balance
  PagarMe::Balance.find_by_recipient_id id
end

#balance_operations(*args) ⇒ Object



21
22
23
# File 'lib/pagarme/resources/recipient.rb', line 21

def balance_operations(*args)
  PagarMe::BalanceOperation.find_by_recipient_id id, *args
end

#bulk_anticipate(params = Hash.new) ⇒ Object



13
14
15
# File 'lib/pagarme/resources/recipient.rb', line 13

def bulk_anticipate(params = Hash.new)
  PagarMe::BulkAnticipation.create params.merge(parent_id: id)
end

#bulk_anticipations(*args, **params) ⇒ Object

Raises:



7
8
9
10
11
# File 'lib/pagarme/resources/recipient.rb', line 7

def bulk_anticipations(*args, **params)
  params = self.class.extract_page_count_or_params(*args, **params)
  raise RequestError.new('Invalid page count') if params[:page] < 1 or params[:count] < 1
  PagarMe::BulkAnticipation.all id, params
end

#bulk_anticipations_limits(params = Hash.new) ⇒ Object



3
4
5
# File 'lib/pagarme/resources/recipient.rb', line 3

def bulk_anticipations_limits(params = Hash.new)
  PagarMe::BulkAnticipation.bulk_anticipations_limits id, params
end

#receive(amount) ⇒ Object



25
26
27
# File 'lib/pagarme/resources/recipient.rb', line 25

def receive(amount)
  PagarMe::Transfer.create recipient_id: id, amount: amount
end