Class: Chargify::Subscription
- Inherits:
-
Base
show all
- Defined in:
- lib/chargify_api_ares.rb
Defined Under Namespace
Classes: Component, Statement, Transaction
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
element_name, #to_xml
Class Method Details
.find_by_customer_reference(reference) ⇒ Object
105
106
107
108
|
# File 'lib/chargify_api_ares.rb', line 105
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
118
119
120
|
# File 'lib/chargify_api_ares.rb', line 118
def cancel
destroy
end
|
#charge(attrs = {}) ⇒ Object
138
139
140
|
# File 'lib/chargify_api_ares.rb', line 138
def charge(attrs = {})
post :charges, {}, attrs.to_xml(:root => :charge)
end
|
#component(id) ⇒ Object
122
123
124
|
# File 'lib/chargify_api_ares.rb', line 122
def component(id)
Component.find(id, :params => {:subscription_id => self.id})
end
|
#components(params = {}) ⇒ Object
126
127
128
129
|
# File 'lib/chargify_api_ares.rb', line 126
def components(params = {})
params.merge!({:subscription_id => self.id})
Component.find(:all, :params => params)
end
|
#credit(attrs = {}) ⇒ Object
142
143
144
|
# File 'lib/chargify_api_ares.rb', line 142
def credit(attrs = {})
post :credits, {}, attrs.to_xml(:root => :credit)
end
|
#migrate(attrs = {}) ⇒ Object
158
159
160
|
# File 'lib/chargify_api_ares.rb', line 158
def migrate(attrs = {})
post :migrations, :migration => attrs
end
|
#payment_profile ⇒ Object
131
132
133
|
# File 'lib/chargify_api_ares.rb', line 131
def payment_profile
credit_card
end
|
#reactivate(params = {}) ⇒ Object
150
151
152
|
# File 'lib/chargify_api_ares.rb', line 150
def reactivate(params = {})
put :reactivate, params
end
|
#refund(attrs = {}) ⇒ Object
146
147
148
|
# File 'lib/chargify_api_ares.rb', line 146
def refund(attrs = {})
post :refunds, {}, attrs.to_xml(:root => :refund)
end
|
#reset_balance ⇒ Object
154
155
156
|
# File 'lib/chargify_api_ares.rb', line 154
def reset_balance
put :reset_balance
end
|
#save ⇒ Object
Strip off nested attributes of associations before saving, or type-mismatch errors will occur
111
112
113
114
115
116
|
# File 'lib/chargify_api_ares.rb', line 111
def save
self.attributes.delete('customer')
self.attributes.delete('product')
self.attributes.delete('credit_card')
super
end
|
#statement(id) ⇒ Object
162
163
164
165
166
|
# File 'lib/chargify_api_ares.rb', line 162
def statement(id)
statement = Chargify::Statement.find(id)
raise ActiveResource::ResourceNotFound.new(nil) if (statement.subscription_id != self.id)
statement
end
|
#statements(params = {}) ⇒ Object
168
169
170
171
|
# File 'lib/chargify_api_ares.rb', line 168
def statements(params = {})
params.merge!(:subscription_id => self.id)
Statement.find(:all, :params => params)
end
|
#transactions(params = {}) ⇒ Object
173
174
175
176
|
# File 'lib/chargify_api_ares.rb', line 173
def transactions(params = {})
params.merge!(:subscription_id => self.id)
Transaction.find(:all, :params => params)
end
|