Class: Centaman::Object::CouponCheck

Inherits:
Centaman::Object show all
Defined in:
lib/centaman/object/coupon_check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Centaman::Object

#define_variables, #initialize

Constructor Details

This class inherits a constructor from Centaman::Object

Instance Attribute Details

#effectsObject (readonly)

Returns the value of attribute effects.



3
4
5
# File 'lib/centaman/object/coupon_check.rb', line 3

def effects
  @effects
end

Instance Method Details

#after_init(args = {}) ⇒ Object



5
6
7
# File 'lib/centaman/object/coupon_check.rb', line 5

def after_init(args = {})
  define_effects(args)
end

#attributesObject

rubocop:disable Metrics/MethodLength



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/centaman/object/coupon_check.rb', line 16

def attributes
  [
    Centaman::Attribute.new(
      centaman_key: 'CouponCode',
      app_key: :coupon_code,
      type: :integer
    ),
    Centaman::Attribute.new(
      centaman_key: 'LimitedUse',
      app_key: :limited_use,
      type: :boolean
    ),
    Centaman::Attribute.new(
      centaman_key: 'UsesRemaining',
      app_key: :uses_remaining,
      type: :integer
    )
  ]
end

#define_effects(args) ⇒ Object



9
10
11
12
13
# File 'lib/centaman/object/coupon_check.rb', line 9

def define_effects(args)
  @effects = args['Effects'].map do |effect_hash|
    Centaman::Object::Effect.new(effect_hash)
  end
end