Class: Bfwd::CouponModifierBase

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

Overview

A coupon-modifier.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CouponModifierBase

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
203
204
205
206
207
208
209
210
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 140

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":[] }



33
34
35
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 33

def changed_by
  @changed_by
end

#coupon_definition_idObject

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



45
46
47
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 45

def coupon_definition_id
  @coupon_definition_id
end

#createdObject

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



30
31
32
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 30

def created
  @created
end

#deletedObject

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



72
73
74
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 72

def deleted
  @deleted
end

#domainObject

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



63
64
65
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 63

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“: }



54
55
56
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 54

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“: }



57
58
59
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 57

def effect_additional
  @effect_additional
end

#effect_amountObject

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



48
49
50
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 48

def effect_amount
  @effect_amount
end

#idObject

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



39
40
41
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 39

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“: }



51
52
53
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 51

def operand
  @operand
end

#organization_idObject

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



42
43
44
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 42

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“: }



69
70
71
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 69

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“: }



66
67
68
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 66

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“: }



60
61
62
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 60

def specifier_amount
  @specifier_amount
end

#updatedObject

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



36
37
38
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 36

def updated
  @updated
end

Class Method Details

.attribute_mapObject

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



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 97

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.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 118

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



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 272

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



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 328

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 =~ /^(true|t|yes|y|1)$/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



394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 394

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



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 307

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/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


294
295
296
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 294

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



300
301
302
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 300

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



214
215
216
217
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 214

def list_invalid_properties
  invalid_properties = Array.new
  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



374
375
376
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 374

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



380
381
382
383
384
385
386
387
388
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 380

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



368
369
370
# File 'lib/bf_ruby2/models/coupon_modifier_base.rb', line 368

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



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

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