Class: PagarMe::Subscription
- Inherits:
-
TransactionCommon
- Object
- PagarMeObject
- Model
- TransactionCommon
- PagarMe::Subscription
- Defined in:
- lib/pagarme/subscription.rb
Instance Method Summary collapse
Methods inherited from TransactionCommon
Methods inherited from Model
all, class_name, find_by, find_by_id, url, #url
Methods inherited from PagarMeObject
#[], #[]=, build, #each, #initialize, #respond_to?, #to_hash, #to_hash_value, #unsaved_values, #update
Constructor Details
This class inherits a constructor from PagarMe::TransactionCommon
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PagarMe::PagarMeObject
Instance Method Details
#cancel ⇒ Object
24 25 26 27 28 |
# File 'lib/pagarme/subscription.rb', line 24 def cancel request = PagarMe::Request.new(self.url + '/cancel', 'POST') response = request.run update(response) end |
#charge(amount, installments = 1) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pagarme/subscription.rb', line 30 def charge(amount, installments = 1) request = PagarMe::Request.new(self.url + '/transactions', 'POST') request.parameters = { :amount => amount, :installments => installments } response = request.run request = PagarMe::Request.new(self.url, 'GET') update(request.run) end |
#create ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/pagarme/subscription.rb', line 6 def create if self.plan self.plan_id = plan.id end self.plan = nil super end |
#save ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/pagarme/subscription.rb', line 15 def save if self.plan self.plan_id = plan.id end self.plan = nil super end |