Class: Chargify::Subscription
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- Chargify::Subscription
- Defined in:
- lib/chargify_api_ares.rb
Defined Under Namespace
Classes: Component
Class Method Summary collapse
Instance Method Summary collapse
- #cancel ⇒ Object
-
#charge(attrs = {}) ⇒ Object
Perform a one-time charge on an existing subscription.
- #component(id) ⇒ Object
- #components(params = {}) ⇒ Object
-
#save ⇒ Object
Strip off nested attributes of associations before saving, or type-mismatch errors will occur.
Methods inherited from Base
Class Method Details
.find_by_customer_reference(reference) ⇒ Object
91 92 93 94 |
# File 'lib/chargify_api_ares.rb', line 91 def self.find_by_customer_reference(reference) customer = Customer.find_by_reference(reference) find(:first, :params => {:customer_id => customer.id}) end |
Instance Method Details
#cancel ⇒ Object
104 105 106 |
# File 'lib/chargify_api_ares.rb', line 104 def cancel destroy end |
#charge(attrs = {}) ⇒ Object
Perform a one-time charge on an existing subscription. For more information, please see the one-time charge API docs available at: support.chargify.com/faqs/api/api-charges
120 121 122 |
# File 'lib/chargify_api_ares.rb', line 120 def charge(attrs = {}) post :charges, :charge => attrs end |
#component(id) ⇒ Object
108 109 110 |
# File 'lib/chargify_api_ares.rb', line 108 def component(id) Component.find(id, :params => {:subscription_id => self.id}) end |
#components(params = {}) ⇒ Object
112 113 114 115 |
# File 'lib/chargify_api_ares.rb', line 112 def components(params = {}) params.merge!({:subscription_id => self.id}) Component.find(:all, :params => params) end |
#save ⇒ Object
Strip off nested attributes of associations before saving, or type-mismatch errors will occur
97 98 99 100 101 102 |
# File 'lib/chargify_api_ares.rb', line 97 def save self.attributes.delete('customer') self.attributes.delete('product') self.attributes.delete('credit_card') super end |