Class: Chargify::Coupon
- Includes:
- ResponseHelper
- Defined in:
- lib/chargify_api_ares/resources/coupon.rb
Class Method Summary collapse
- .find_all_by_product_family_id(product_family_id) ⇒ Object
- .find_by_product_family_id_and_code(product_family_id, code) ⇒ Object
- .validate(params = {}) ⇒ Object
Instance Method Summary collapse
Methods inherited from Base
Class Method Details
.find_all_by_product_family_id(product_family_id) ⇒ Object
5 6 7 |
# File 'lib/chargify_api_ares/resources/coupon.rb', line 5 def self.find_all_by_product_family_id(product_family_id) Coupon.find(:all, :params => { :product_family_id => product_family_id }) end |
.find_by_product_family_id_and_code(product_family_id, code) ⇒ Object
9 10 11 |
# File 'lib/chargify_api_ares/resources/coupon.rb', line 9 def self.find_by_product_family_id_and_code(product_family_id, code) find(:one, :from => :lookup, :params => {:product_family_id => product_family_id, :code => code}) end |
.validate(params = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/chargify_api_ares/resources/coupon.rb', line 13 def self.validate(params = {}) product_family_id = params.fetch(:product_family_id, nil) coupon_code = params.fetch(:coupon_code, nil) raise ArgumentError, 'coupon_code is a required argument' if coupon_code.blank? params = {:coupon_code => coupon_code} params.merge!(:product_family_id => product_family_id) if product_family_id.present? find :one, :from => :validate, :params => params end |
Instance Method Details
#archive ⇒ Object
31 32 33 |
# File 'lib/chargify_api_ares/resources/coupon.rb', line 31 def archive self.destroy end |
#usage ⇒ Object
25 26 27 28 29 |
# File 'lib/chargify_api_ares/resources/coupon.rb', line 25 def usage process_capturing_errors do get :usage end end |