Class: Celery::Coupon
- Inherits:
-
Object
- Object
- Celery::Coupon
- Defined in:
- lib/celery/resources/coupon.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
Instance Method Summary collapse
-
#all(params = {}) ⇒ JSON
Returns a list of coupons you have.
-
#destroy(coupon_id) ⇒ JSON
Deletes an existing coupon object.
-
#find(coupon_id) ⇒ JSON
Retrieves a coupon that has previously been created.
-
#initialize(api) ⇒ Coupon
constructor
A new instance of Coupon.
-
#new(coupon) ⇒ JSON
Creates a new coupon object.
-
#update(coupon_id, coupon) ⇒ JSON
Updates an existing coupon object.
Constructor Details
#initialize(api) ⇒ Coupon
Returns a new instance of Coupon.
5 6 7 |
# File 'lib/celery/resources/coupon.rb', line 5 def initialize(api) @api = api end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
3 4 5 |
# File 'lib/celery/resources/coupon.rb', line 3 def api @api end |
Instance Method Details
#all(params = {}) ⇒ JSON
Returns a list of coupons you have. The coupons are returned in sorted order, with the most recent coupons appearing first.
33 34 35 |
# File 'lib/celery/resources/coupon.rb', line 33 def all(params = {}) @api.get("coupons", query: params) end |
#destroy(coupon_id) ⇒ JSON
Deletes an existing coupon object.
132 133 134 |
# File 'lib/celery/resources/coupon.rb', line 132 def destroy(coupon_id) @api.delete("coupons/#{coupon_id}") end |
#find(coupon_id) ⇒ JSON
Retrieves a coupon that has previously been created.
54 55 56 |
# File 'lib/celery/resources/coupon.rb', line 54 def find(coupon_id) @api.get("coupons/#{coupon_id}") end |
#new(coupon) ⇒ JSON
Creates a new coupon object.
83 84 85 |
# File 'lib/celery/resources/coupon.rb', line 83 def new(coupon) @api.post("coupons", body: {coupon: coupon}) end |
#update(coupon_id, coupon) ⇒ JSON
Updates an existing coupon object.
113 114 115 |
# File 'lib/celery/resources/coupon.rb', line 113 def update(coupon_id, coupon) @api.put("coupons/#{coupon_id}", body: {coupon: coupon}) end |