Class: HitfoxCouponApi::Order
- Defined in:
- lib/hitfox_coupon_api/order.rb
Constant Summary
Constants inherited from Client
Instance Attribute Summary collapse
-
#order_id ⇒ Object
Returns the value of attribute order_id.
Instance Method Summary collapse
-
#coupons ⇒ Object
Return a list of coupons of this order.
-
#initialize(application, order_id) ⇒ Order
constructor
A new instance of Order.
-
#paid ⇒ Object
Make as paid the coupons attached to the order.
-
#reserve(count = 1) ⇒ Object
Reserve count coupons for an order.
Methods inherited from Client
#apiheaders, #configuration, #generate_url, #handle_coupon_results
Constructor Details
#initialize(application, order_id) ⇒ Order
Returns a new instance of Order.
5 6 7 |
# File 'lib/hitfox_coupon_api/order.rb', line 5 def initialize(application, order_id) @application, @order_id = application, order_id end |
Instance Attribute Details
#order_id ⇒ Object
Returns the value of attribute order_id.
3 4 5 |
# File 'lib/hitfox_coupon_api/order.rb', line 3 def order_id @order_id end |
Instance Method Details
#coupons ⇒ Object
Return a list of coupons of this order. Once again, this will only provide a list of coupons that are attached to this application.
29 30 31 32 33 |
# File 'lib/hitfox_coupon_api/order.rb', line 29 def coupons headers, params = build_request_data urlstr = generate_url('/%s/coupon/%s/list.json?hash=%s', params) handle_coupon_results(JSON.parse(RestClient.get(urlstr, headers))) end |
#paid ⇒ Object
Make as paid the coupons attached to the order. Once again, this is related only to those coupons that are from this application. If an order contains coupons from an application, then they need to be marked paid separately.
21 22 23 24 25 |
# File 'lib/hitfox_coupon_api/order.rb', line 21 def paid headers, params = build_request_data urlstr = generate_url('/%s/coupon/%s/paid.json?hash=%s', params) handle_coupon_results(JSON.parse(RestClient.get(urlstr, headers))) end |
#reserve(count = 1) ⇒ Object
Reserve count coupons for an order. These are reserved for a specific application, if an order contains multiple products/deals/applications, then this needs to called once for each.
12 13 14 15 16 |
# File 'lib/hitfox_coupon_api/order.rb', line 12 def reserve(count = 1) headers, params = build_request_data urlstr = generate_url('/%s/coupon/%s/reserve.json?hash=%s&count=%s', params + [count.to_s]) handle_coupon_results(JSON.parse(RestClient.get(urlstr, headers))) end |