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, 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



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

def self.default
  Company.default_recipient
end

Instance Method Details

#balanceObject



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

def balance
  PagarMe::Balance.find_by_recipient_id id
end

#balance_operations(*args) ⇒ Object



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

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

#bulk_anticipate(params = Hash.new) ⇒ Object



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

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

#bulk_anticipations(page = 1, count = 10) ⇒ Object

Raises:



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

def bulk_anticipations(page = 1, count = 10)
  raise RequestError.new('Invalid page count') if page < 1 or count < 1
  PagarMe::BulkAnticipation.all id, page, count
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



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

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