Class: HitfoxCouponApi::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/hitfox_coupon_api/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#identifierObject (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

Returns:

  • (Boolean)


22
23
24
# File 'lib/hitfox_coupon_api/application.rb', line 22

def available?(count = 1)
  Coupon.new(self,nil).available?(count)
end

#configurationObject

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

#configureObject



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

#order(order_id) ⇒ Object



17
18
19
# File 'lib/hitfox_coupon_api/application.rb', line 17

def order(order_id)
  Order.new(self, order_id)
end

#user(user_id) ⇒ Object



13
14
15
# File 'lib/hitfox_coupon_api/application.rb', line 13

def user(user_id)
  User.new(self, user_id)
end