Class: Bfwd::ProductCouponModifier

Inherits:
Object
  • Object
show all
Defined in:
lib/bf_ruby2/models/product_coupon_modifier.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ProductCouponModifier

Initializes the object

Parameters:

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

    Model attributes in the form of hash



129
130
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
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 129

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'created')
    self.created = attributes[:'created']
  end

  if attributes.has_key?(:'changedBy')
    self.changed_by = attributes[:'changedBy']
  end

  if attributes.has_key?(:'updated')
    self.updated = attributes[:'updated']
  end

  if attributes.has_key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'organizationID')
    self.organization_id = attributes[:'organizationID']
  end

  if attributes.has_key?(:'couponDefinitionID')
    self.coupon_definition_id = attributes[:'couponDefinitionID']
  end

  if attributes.has_key?(:'effectAmount')
    self.effect_amount = attributes[:'effectAmount']
  end

  if attributes.has_key?(:'operand')
    self.operand = attributes[:'operand']
  end

  if attributes.has_key?(:'effect')
    self.effect = attributes[:'effect']
  end

  if attributes.has_key?(:'effectAdditional')
    self.effect_additional = attributes[:'effectAdditional']
  else
    self.effect_additional = false
  end

  if attributes.has_key?(:'specifierAmount')
    self.specifier_amount = attributes[:'specifierAmount']
  end

  if attributes.has_key?(:'domain')
    self.domain = attributes[:'domain']
  end

  if attributes.has_key?(:'specifier')
    self.specifier = attributes[:'specifier']
  end

  if attributes.has_key?(:'precedence')
    self.precedence = attributes[:'precedence']
  end

  if attributes.has_key?(:'deleted')
    self.deleted = attributes[:'deleted']
  else
    self.deleted = false
  end

end

Instance Attribute Details

#changed_byObject

{ "description" : "ID of the user who last updated the entity.", "verbs":[] }



22
23
24
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 22

def changed_by
  @changed_by
end

#coupon_definition_idObject

{ "description" : "The unique ID of the coupon-definition associated with the coupon-modifier.", "verbs“: }



34
35
36
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 34

def coupon_definition_id
  @coupon_definition_id
end

#createdObject

{ "description" : "The UTC DateTime when the object was created.", "verbs":[] }



19
20
21
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 19

def created
  @created
end

#deletedObject

{ "description" : "Has the coupon-modifier been deleted.", "verbs“: }



61
62
63
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 61

def deleted
  @deleted
end

#domainObject

{ "description" : "The domain of the coupon-modifier", "verbs“: }



52
53
54
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 52

def domain
  @domain
end

#effectObject

{ "description" : "The effect of the coupon-modifier. The coupon-modifier can affect first, last, and cheapest value of a specific unit-of-measure-id for a subscription. The coupon-modifier can also affect all of the values for a unit-of-measure-id, or can affect all of the subscription cost.", "verbs“: }



43
44
45
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 43

def effect
  @effect
end

#effect_additionalObject

{ "description" : "Specifies whether the coupon-modifier will be affecting only additional units. If this field is set, the coupon-instance-existing-values for the coupon-instance are observed, and any units of the unit-of-measure-id defined by the modifier below the coupon-instance-existing-values for that unit-of-measure-id will be ignored.", "verbs“: }



46
47
48
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 46

def effect_additional
  @effect_additional
end

#effect_amountObject

{ "description" : "The effect amount for the coupon-modifier. This is affected by the operand field.", "verbs“: }



37
38
39
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 37

def effect_amount
  @effect_amount
end

#idObject

{ "description" : "ID of the coupon-modifier.", "verbs“: }



28
29
30
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 28

def id
  @id
end

#operandObject

{ "description" : "The operand field affects the effect amount of the coupon-modifier. If the operand is fixed, it is an exact amount of the currency defined by the coupon-definition. If the operand is percent, this means the coupon will be affecting a percentage of the unaltered cost. E.g. a 25% modifier will apply a 25% discount on a subscription or a pricing-component.", "verbs“: }



40
41
42
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 40

def operand
  @operand
end

#organization_idObject

{ "description" : "ID of the organization associated with the coupon-modifier.", "verbs“: }



31
32
33
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 31

def organization_id
  @organization_id
end

#precedenceObject

{ "description" : "The precedence of the coupon-modifier. This is used to order application of coupon-modifiers. Higher precedence means the coupon-modifier will be applied before others.", "verbs“: }



58
59
60
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 58

def precedence
  @precedence
end

#specifierObject

{ "description" : "The specifier is domain-specific. If the domain is uom, this field is used to limit the coupon-modifier to a specific unit-of-measure-id.", "verbs“: }



55
56
57
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 55

def specifier
  @specifier
end

#specifier_amountObject

{ "description" : "The number of units that will be affected by the coupon-modifier, if the domain is set to uom", "verbs“: }



49
50
51
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 49

def specifier_amount
  @specifier_amount
end

#updatedObject

{ "description" : "The UTC DateTime when the object was last updated.", "verbs":[] }



25
26
27
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 25

def updated
  @updated
end

Class Method Details

.attribute_mapObject

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



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 86

def self.attribute_map
  {
    :'created' => :'created',
    :'changed_by' => :'changedBy',
    :'updated' => :'updated',
    :'id' => :'id',
    :'organization_id' => :'organizationID',
    :'coupon_definition_id' => :'couponDefinitionID',
    :'effect_amount' => :'effectAmount',
    :'operand' => :'operand',
    :'effect' => :'effect',
    :'effect_additional' => :'effectAdditional',
    :'specifier_amount' => :'specifierAmount',
    :'domain' => :'domain',
    :'specifier' => :'specifier',
    :'precedence' => :'precedence',
    :'deleted' => :'deleted'
  }
end

.swagger_typesObject

Attribute type mapping.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 107

def self.swagger_types
  {
    :'created' => :'DateTime',
    :'changed_by' => :'String',
    :'updated' => :'DateTime',
    :'id' => :'String',
    :'organization_id' => :'String',
    :'coupon_definition_id' => :'String',
    :'effect_amount' => :'Float',
    :'operand' => :'String',
    :'effect' => :'String',
    :'effect_additional' => :'BOOLEAN',
    :'specifier_amount' => :'Integer',
    :'domain' => :'String',
    :'specifier' => :'String',
    :'precedence' => :'Integer',
    :'deleted' => :'BOOLEAN'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 297

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created == o.created &&
      changed_by == o.changed_by &&
      updated == o.updated &&
      id == o.id &&
      organization_id == o.organization_id &&
      coupon_definition_id == o.coupon_definition_id &&
      effect_amount == o.effect_amount &&
      operand == o.operand &&
      effect == o.effect &&
      effect_additional == o.effect_additional &&
      specifier_amount == o.specifier_amount &&
      domain == o.domain &&
      specifier == o.specifier &&
      precedence == o.precedence &&
      deleted == o.deleted
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 353

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = Bfwd.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 419

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map{ |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
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



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 332

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


319
320
321
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 319

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



325
326
327
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 325

def hash
  [created, changed_by, updated, id, organization_id, coupon_definition_id, effect_amount, operand, effect, effect_additional, specifier_amount, domain, specifier, precedence, deleted].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 203

def list_invalid_properties
  invalid_properties = Array.new
  if @organization_id.nil?
    invalid_properties.push("invalid value for 'organization_id', organization_id cannot be nil.")
  end

  if @effect_amount.nil?
    invalid_properties.push("invalid value for 'effect_amount', effect_amount cannot be nil.")
  end

  if @operand.nil?
    invalid_properties.push("invalid value for 'operand', operand cannot be nil.")
  end

  if @effect.nil?
    invalid_properties.push("invalid value for 'effect', effect cannot be nil.")
  end

  if @effect_additional.nil?
    invalid_properties.push("invalid value for 'effect_additional', effect_additional cannot be nil.")
  end

  if @specifier_amount.nil?
    invalid_properties.push("invalid value for 'specifier_amount', specifier_amount cannot be nil.")
  end

  if @domain.nil?
    invalid_properties.push("invalid value for 'domain', domain cannot be nil.")
  end

  if @precedence.nil?
    invalid_properties.push("invalid value for 'precedence', precedence cannot be nil.")
  end

  if @deleted.nil?
    invalid_properties.push("invalid value for 'deleted', deleted cannot be nil.")
  end

  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



399
400
401
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 399

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



405
406
407
408
409
410
411
412
413
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 405

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



393
394
395
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 393

def to_s
  to_hash.to_s
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/bf_ruby2/models/product_coupon_modifier.rb', line 246

def valid?
  return false if @organization_id.nil?
  return false if @effect_amount.nil?
  return false if @operand.nil?
  operand_validator = EnumAttributeValidator.new('String', ["fixed", "percent", "instance_fixed", "instance_percent"])
  return false unless operand_validator.valid?(@operand)
  return false if @effect.nil?
  effect_validator = EnumAttributeValidator.new('String', ["discount_first_units", "discount_last_units", "discount_cheapest_units", "discount_all"])
  return false unless effect_validator.valid?(@effect)
  return false if @effect_additional.nil?
  return false if @specifier_amount.nil?
  return false if @domain.nil?
  domain_validator = EnumAttributeValidator.new('String', ["product", "uom", "PricingComponent"])
  return false unless domain_validator.valid?(@domain)
  return false if @precedence.nil?
  return false if @deleted.nil?
  return true
end