Class: Ifeelgoods::Dimension

Inherits:
ApiModelBase show all
Defined in:
lib/ifeelgoods/models/dimension.rb

Overview

Additional structured attributes associated with a reward. Each key represents a dimension label and its value is the dimension value for that reward. Not all dimensions are present on every reward — only the ones configured for that specific product will appear.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Dimension

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/ifeelgoods/models/dimension.rb', line 131

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Ifeelgoods::Dimension` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Ifeelgoods::Dimension`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'available_denominations_range')
    self.available_denominations_range = attributes[:'available_denominations_range']
  end

  if attributes.key?(:'custom_offer')
    self.custom_offer = attributes[:'custom_offer']
  end

  if attributes.key?(:'validity_period')
    self.validity_period = attributes[:'validity_period']
  end

  if attributes.key?(:'available_denominations')
    self.available_denominations = attributes[:'available_denominations']
  end

  if attributes.key?(:'breakable')
    self.breakable = attributes[:'breakable']
  end

  if attributes.key?(:'cumulable')
    self.cumulable = attributes[:'cumulable']
  end

  if attributes.key?(:'denomination')
    self.denomination = attributes[:'denomination']
  end

  if attributes.key?(:'denomination_currency')
    self.denomination_currency = attributes[:'denomination_currency']
  end

  if attributes.key?(:'duration')
    self.duration = attributes[:'duration']
  end

  if attributes.key?(:'duration_unit')
    self.duration_unit = attributes[:'duration_unit']
  end

  if attributes.key?(:'people')
    self.people = attributes[:'people']
  end

  if attributes.key?(:'quantity')
    self.quantity = attributes[:'quantity']
  end

  if attributes.key?(:'quantity_unit')
    self.quantity_unit = attributes[:'quantity_unit']
  end

  if attributes.key?(:'redemption_channel')
    if (value = attributes[:'redemption_channel']).is_a?(Array)
      self.redemption_channel = value
    end
  end
end

Instance Attribute Details

#available_denominationsObject

List of specific monetary amounts available for this reward.



29
30
31
# File 'lib/ifeelgoods/models/dimension.rb', line 29

def available_denominations
  @available_denominations
end

#available_denominations_rangeObject

Indicates the range of values that can be used with open value reward (when free_value is true) (eg. 5..250).



20
21
22
# File 'lib/ifeelgoods/models/dimension.rb', line 20

def available_denominations_range
  @available_denominations_range
end

#breakableObject

Indicates whether the reward code can be broken into smaller values.



32
33
34
# File 'lib/ifeelgoods/models/dimension.rb', line 32

def breakable
  @breakable
end

#cumulableObject

Indicates whether multiple reward codes can be combined.



35
36
37
# File 'lib/ifeelgoods/models/dimension.rb', line 35

def cumulable
  @cumulable
end

#custom_offerObject

When a custom offer has been configured for this product (eg. buy one get one, $20 off the second article, etc.).



23
24
25
# File 'lib/ifeelgoods/models/dimension.rb', line 23

def custom_offer
  @custom_offer
end

#denominationObject

Returns the value of attribute denomination.



37
38
39
# File 'lib/ifeelgoods/models/dimension.rb', line 37

def denomination
  @denomination
end

#denomination_currencyObject

Currency of the denomination amount (eg. EUR, USD, etc.).



40
41
42
# File 'lib/ifeelgoods/models/dimension.rb', line 40

def denomination_currency
  @denomination_currency
end

#durationObject

Duration of a subscription or service (eg. 2 months).



43
44
45
# File 'lib/ifeelgoods/models/dimension.rb', line 43

def duration
  @duration
end

#duration_unitObject

Unit of the duration dimension. Possible values: minute, hour, day, week, month, year, varying_duration.



46
47
48
# File 'lib/ifeelgoods/models/dimension.rb', line 46

def duration_unit
  @duration_unit
end

#peopleObject

Number of people concerned by the reward.



49
50
51
# File 'lib/ifeelgoods/models/dimension.rb', line 49

def people
  @people
end

#quantityObject

Virtual currency amount associated with the reward (eg. 300 points, 200 miles, etc.).



52
53
54
# File 'lib/ifeelgoods/models/dimension.rb', line 52

def quantity
  @quantity
end

#quantity_unitObject

Unit of the quantity dimension. Possible values: points, miles, facebook_credits, minutes, movie, meal, e_magazine, e_ticket, song, lesson, box, subscription.



55
56
57
# File 'lib/ifeelgoods/models/dimension.rb', line 55

def quantity_unit
  @quantity_unit
end

#redemption_channelObject

Returns the value of attribute redemption_channel.



57
58
59
# File 'lib/ifeelgoods/models/dimension.rb', line 57

def redemption_channel
  @redemption_channel
end

#validity_periodObject

Duration during which the reward code remains valid after delivery. Expressed as a number followed by a unit: d for days, m for months, y for years (eg. 30d for 30 days, 12m for 12 months, 1y for 1 year). Returns null if no validity period applies.



26
27
28
# File 'lib/ifeelgoods/models/dimension.rb', line 26

def validity_period
  @validity_period
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



80
81
82
# File 'lib/ifeelgoods/models/dimension.rb', line 80

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



85
86
87
# File 'lib/ifeelgoods/models/dimension.rb', line 85

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ifeelgoods/models/dimension.rb', line 60

def self.attribute_map
  {
    :'available_denominations_range' => :'available_denominations_range',
    :'custom_offer' => :'custom_offer',
    :'validity_period' => :'validity_period',
    :'available_denominations' => :'available_denominations',
    :'breakable' => :'breakable',
    :'cumulable' => :'cumulable',
    :'denomination' => :'denomination',
    :'denomination_currency' => :'denomination_currency',
    :'duration' => :'duration',
    :'duration_unit' => :'duration_unit',
    :'people' => :'people',
    :'quantity' => :'quantity',
    :'quantity_unit' => :'quantity_unit',
    :'redemption_channel' => :'redemption_channel'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/ifeelgoods/models/dimension.rb', line 255

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ifeelgoods/models/dimension.rb', line 110

def self.openapi_nullable
  Set.new([
    :'available_denominations_range',
    :'custom_offer',
    :'validity_period',
    :'available_denominations',
    :'breakable',
    :'cumulable',
    :'denomination',
    :'denomination_currency',
    :'duration',
    :'duration_unit',
    :'people',
    :'quantity',
    :'quantity_unit',
    :'redemption_channel'
  ])
end

.openapi_typesObject

Attribute type mapping.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/ifeelgoods/models/dimension.rb', line 90

def self.openapi_types
  {
    :'available_denominations_range' => :'String',
    :'custom_offer' => :'String',
    :'validity_period' => :'String',
    :'available_denominations' => :'String',
    :'breakable' => :'String',
    :'cumulable' => :'String',
    :'denomination' => :'DimensionDenomination',
    :'denomination_currency' => :'String',
    :'duration' => :'String',
    :'duration_unit' => :'String',
    :'people' => :'String',
    :'quantity' => :'String',
    :'quantity_unit' => :'String',
    :'redemption_channel' => :'Array<String>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/ifeelgoods/models/dimension.rb', line 221

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      available_denominations_range == o.available_denominations_range &&
      custom_offer == o.custom_offer &&
      validity_period == o.validity_period &&
      available_denominations == o.available_denominations &&
      breakable == o.breakable &&
      cumulable == o.cumulable &&
      denomination == o.denomination &&
      denomination_currency == o.denomination_currency &&
      duration == o.duration &&
      duration_unit == o.duration_unit &&
      people == o.people &&
      quantity == o.quantity &&
      quantity_unit == o.quantity_unit &&
      redemption_channel == o.redemption_channel
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


242
243
244
# File 'lib/ifeelgoods/models/dimension.rb', line 242

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



248
249
250
# File 'lib/ifeelgoods/models/dimension.rb', line 248

def hash
  [available_denominations_range, custom_offer, validity_period, available_denominations, breakable, cumulable, denomination, denomination_currency, duration, duration_unit, people, quantity, quantity_unit, redemption_channel].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



206
207
208
209
210
# File 'lib/ifeelgoods/models/dimension.rb', line 206

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/ifeelgoods/models/dimension.rb', line 277

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



214
215
216
217
# File 'lib/ifeelgoods/models/dimension.rb', line 214

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  true
end