Class: HitfoxCouponApi::Application
- Inherits:
-
Object
- Object
- HitfoxCouponApi::Application
- Defined in:
- lib/hitfox_coupon_api/application.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
-
#add_coupons(cpns_code) ⇒ Object
take an array of coupon details and create deal coupons.
- #add_coupons!(cpns_code) ⇒ Object
-
#available?(count = 1) ⇒ Boolean
return the true/false if count coupons are available for the application.
-
#configuration ⇒ Object
Allow an application to have a specific configuration.
- #configure ⇒ Object
- #coupon(code) ⇒ Object
-
#initialize(identifier) ⇒ Application
constructor
A new instance of Application.
- #order(order_id) ⇒ Object
- #user(user_id) ⇒ Object
Constructor Details
#initialize(identifier) ⇒ Application
Returns a new instance of Application.
5 6 7 |
# File 'lib/hitfox_coupon_api/application.rb', line 5 def initialize(identifier) @identifier = identifier end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/hitfox_coupon_api/application.rb', line 3 def identifier @identifier end |
Instance Method Details
#add_coupons(cpns_code) ⇒ Object
take an array of coupon details and create deal coupons. The array is assumed to be structured as: [type, code, type, code, link, type, code, type, code, … etc] where type is one of: :actlink (2 args), :ingame (1 arg), :url (1 arg), e.g.
[:actlink, code, link, :ingame, code, :url, link, :ingame, code, ....]
would a valid array.
31 32 33 |
# File 'lib/hitfox_coupon_api/application.rb', line 31 def add_coupons(cpns_code) Coupon.new(self,nil).add(cpns_code) end |
#add_coupons!(cpns_code) ⇒ Object
34 35 36 |
# File 'lib/hitfox_coupon_api/application.rb', line 34 def add_coupons!(cpns_code) Coupon.new(self,nil).add!(cpns_code) end |
#available?(count = 1) ⇒ Boolean
return the true/false if count coupons are available for the application
22 23 24 |
# File 'lib/hitfox_coupon_api/application.rb', line 22 def available?(count = 1) Coupon.new(self,nil).available?(count) end |
#configuration ⇒ Object
Allow an application to have a specific configuration. This allows one company to manage multiple products.
40 41 42 |
# File 'lib/hitfox_coupon_api/application.rb', line 40 def configuration @configuration end |
#configure ⇒ Object
44 45 46 47 48 |
# File 'lib/hitfox_coupon_api/application.rb', line 44 def configure @configuration ||= HitfoxCouponApi.configuration.dup block_given? ? yield(@configuration) : @configuration @configuration end |
#coupon(code) ⇒ Object
9 10 11 |
# File 'lib/hitfox_coupon_api/application.rb', line 9 def coupon(code) Coupon.new(self, code) end |