Class: Bfwd::PricingComponent

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

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PricingComponent

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/bf_ruby2/models/pricing_component.rb', line 179

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?(:'@type')
    self.type = attributes[:'@type']
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  if attributes.has_key?(:'unitOfMeasure')
    self.unit_of_measure = attributes[:'unitOfMeasure']
  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/pricing_component.rb', line 22

def changed_by
  @changed_by
end

#charge_modelObject

{ "description" : "The charge model of the pricing-component.", "verbs“: }



64
65
66
# File 'lib/bf_ruby2/models/pricing_component.rb', line 64

def charge_model
  @charge_model
end

#charge_typeObject

{ "description" : "The charge type of the pricing-component.", "verbs“: }



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

def charge_type
  @charge_type
end

#createdObject

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



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

def created
  @created
end

#crm_idObject

{ "description" : "", "verbs“: }



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

def crm_id
  @crm_id
end

#default_quantityObject

{ "description" : "The default quantity of the pricing-component. If no value is supplied on a subscription this value will be used. This is useful for setting an expected purchase level of for introducing new pricing components to existing subscriptions and not having to back-fill values", "verbs“: }



73
74
75
# File 'lib/bf_ruby2/models/pricing_component.rb', line 73

def default_quantity
  @default_quantity
end

#descriptionObject

{ "description" : "", "verbs“: }



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

def description
  @description
end

#downgrade_modeObject

class=\"label label-default\">delayed</span>","description":"Default behaviour when a value is downgraded using this pricing component, this behaviour can be overridden when changing the value.
<span class=\"label label-default\">immediate</span> &mdash; Downgrade will apply at the time the request is made.
<span class=\"label label-default\">delayed</span> &mdash; Downgrade will apply at the end of the current billing cycle.“,”verbs“:



70
71
72
# File 'lib/bf_ruby2/models/pricing_component.rb', line 70

def downgrade_mode
  @downgrade_mode
end

#idObject

{ "description" : "", "verbs“: } When associating a pricing component with a product rate plan, this ID should be used.



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

def id
  @id
end

#invoicing_typeObject

{ "default" : "Aggregated", "description" : "For <span class=\"label label-default\">setup</span> pricing components <span class=\"label label-default\">Immediate</span> invoicing will result in an invoice being issued on subscription being set to the AwaitingPayment state, irrespective of the subscription start date. <span class=\"label label-default\">Aggregated</span> invoicing will add a charge to the first invoice of the subscription.", "verbs“: }



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

def invoicing_type
  @invoicing_type
end

#max_quantityObject

{ "description" : "The maximum quantity of the pricing-component.", "verbs":[] }



79
80
81
# File 'lib/bf_ruby2/models/pricing_component.rb', line 79

def max_quantity
  @max_quantity
end

#min_quantityObject

{ "default" : "0", "description" : "The minimum quantity of the pricing-component.", "verbs":[] }



76
77
78
# File 'lib/bf_ruby2/models/pricing_component.rb', line 76

def min_quantity
  @min_quantity
end

#nameObject

{ "description" : "", "verbs“: }



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

def name
  @name
end

#organization_idObject

{ "description" : "", "verbs":[] }



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

def organization_id
  @organization_id
end

#product_rate_plan_idObject

{ "description" : "", "verbs“: }



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

def product_rate_plan_id
  @product_rate_plan_id
end

#public_nameObject

friendly non-unique name used to identify this pricing-component“,”verbs“:



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

def public_name
  @public_name
end

#tiersObject

{ "default" : "[]", "description" : "The pricing-component-tiers associated with the pricing-component.", "verbs“: }



88
89
90
# File 'lib/bf_ruby2/models/pricing_component.rb', line 88

def tiers
  @tiers
end

#typeObject

{ "description" : "", "default" : "", "verbs“: }



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

def type
  @type
end

#unit_of_measureObject

{ "description" : "The unit-of-measure associated with the pricing-component.", "verbs“: }



91
92
93
# File 'lib/bf_ruby2/models/pricing_component.rb', line 91

def unit_of_measure
  @unit_of_measure
end

#unit_of_measure_idObject

{ "description" : "", "verbs“: }



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

def unit_of_measure_id
  @unit_of_measure_id
end

#updatedObject

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



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

def updated
  @updated
end

#upgrade_modeObject

class=\"label label-default\">immediate</span>","description":"Default behaviour when a value is upgraded using this pricing component, this behaviour can be overridden when changing the value.
<span class=\"label label-default\">immediate</span> &mdash; Upgrade will apply at the time the request is made.
<span class=\"label label-default\">delayed</span> &mdash; Upgrade will apply at the end of the current billing cycle.“,”verbs“:



67
68
69
# File 'lib/bf_ruby2/models/pricing_component.rb', line 67

def upgrade_mode
  @upgrade_mode
end

#valid_fromObject

{ "default" : "current time", "description" : "The DateTime specifying when the pricing-component is valid from.", "verbs“: }



82
83
84
# File 'lib/bf_ruby2/models/pricing_component.rb', line 82

def valid_from
  @valid_from
end

#valid_tillObject

{ "default" : "null", "description" : "The UTC DateTime specifying when the pricing-component is valid till.", "verbs“: }



85
86
87
# File 'lib/bf_ruby2/models/pricing_component.rb', line 85

def valid_till
  @valid_till
end

#version_idObject

{ "description" : "", "verbs“: }



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

def version_id
  @version_id
end

Class Method Details

.attribute_mapObject

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



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/bf_ruby2/models/pricing_component.rb', line 116

def self.attribute_map
  {
    :'created' => :'created',
    :'changed_by' => :'changedBy',
    :'updated' => :'updated',
    :'type' => :'@type',
    :'version_id' => :'versionID',
    :'crm_id' => :'crmID',
    :'id' => :'id',
    :'product_rate_plan_id' => :'productRatePlanID',
    :'unit_of_measure_id' => :'unitOfMeasureID',
    :'organization_id' => :'organizationID',
    :'name' => :'name',
    :'public_name' => :'publicName',
    :'description' => :'description',
    :'charge_type' => :'chargeType',
    :'invoicing_type' => :'invoicingType',
    :'charge_model' => :'chargeModel',
    :'upgrade_mode' => :'upgradeMode',
    :'downgrade_mode' => :'downgradeMode',
    :'default_quantity' => :'defaultQuantity',
    :'min_quantity' => :'minQuantity',
    :'max_quantity' => :'maxQuantity',
    :'valid_from' => :'validFrom',
    :'valid_till' => :'validTill',
    :'tiers' => :'tiers',
    :'unit_of_measure' => :'unitOfMeasure'
  }
end

.swagger_typesObject

Attribute type mapping.



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
# File 'lib/bf_ruby2/models/pricing_component.rb', line 147

def self.swagger_types
  {
    :'created' => :'DateTime',
    :'changed_by' => :'String',
    :'updated' => :'DateTime',
    :'type' => :'String',
    :'version_id' => :'String',
    :'crm_id' => :'String',
    :'id' => :'String',
    :'product_rate_plan_id' => :'String',
    :'unit_of_measure_id' => :'String',
    :'organization_id' => :'String',
    :'name' => :'String',
    :'public_name' => :'String',
    :'description' => :'String',
    :'charge_type' => :'String',
    :'invoicing_type' => :'String',
    :'charge_model' => :'String',
    :'upgrade_mode' => :'String',
    :'downgrade_mode' => :'String',
    :'default_quantity' => :'Integer',
    :'min_quantity' => :'Integer',
    :'max_quantity' => :'Integer',
    :'valid_from' => :'DateTime',
    :'valid_till' => :'DateTime',
    :'tiers' => :'Array<PricingComponentTier>',
    :'unit_of_measure' => :'UnitOfMeasure'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/bf_ruby2/models/pricing_component.rb', line 431

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created == o.created &&
      changed_by == o.changed_by &&
      updated == o.updated &&
      type == o.type &&
      version_id == o.version_id &&
      crm_id == o.crm_id &&
      id == o.id &&
      product_rate_plan_id == o.product_rate_plan_id &&
      unit_of_measure_id == o.unit_of_measure_id &&
      organization_id == o.organization_id &&
      name == o.name &&
      public_name == o.public_name &&
      description == o.description &&
      charge_type == o.charge_type &&
      invoicing_type == o.invoicing_type &&
      charge_model == o.charge_model &&
      upgrade_mode == o.upgrade_mode &&
      downgrade_mode == o.downgrade_mode &&
      default_quantity == o.default_quantity &&
      min_quantity == o.min_quantity &&
      max_quantity == o.max_quantity &&
      valid_from == o.valid_from &&
      valid_till == o.valid_till &&
      tiers == o.tiers &&
      unit_of_measure == o.unit_of_measure
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



497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/bf_ruby2/models/pricing_component.rb', line 497

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



563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/bf_ruby2/models/pricing_component.rb', line 563

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



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/bf_ruby2/models/pricing_component.rb', line 476

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


463
464
465
# File 'lib/bf_ruby2/models/pricing_component.rb', line 463

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



469
470
471
# File 'lib/bf_ruby2/models/pricing_component.rb', line 469

def hash
  [created, changed_by, updated, type, version_id, crm_id, id, product_rate_plan_id, unit_of_measure_id, organization_id, name, public_name, description, charge_type, invoicing_type, charge_model, upgrade_mode, downgrade_mode, default_quantity, min_quantity, max_quantity, valid_from, valid_till, tiers, unit_of_measure].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/bf_ruby2/models/pricing_component.rb', line 291

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

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

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

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

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

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

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

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

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

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

  if @valid_from.nil?
    invalid_properties.push("invalid value for 'valid_from', valid_from 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



543
544
545
# File 'lib/bf_ruby2/models/pricing_component.rb', line 543

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



549
550
551
552
553
554
555
556
557
# File 'lib/bf_ruby2/models/pricing_component.rb', line 549

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



537
538
539
# File 'lib/bf_ruby2/models/pricing_component.rb', line 537

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



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/bf_ruby2/models/pricing_component.rb', line 342

def valid?
  return false if @type.nil?
  type_validator = EnumAttributeValidator.new('String', ["tieredPricingComponent", "flatPricingComponent", "tieredVolumePricingComponent"])
  return false unless type_validator.valid?(@type)
  return false if @version_id.nil?
  return false if @id.nil?
  return false if @product_rate_plan_id.nil?
  return false if @unit_of_measure_id.nil?
  return false if @organization_id.nil?
  return false if @name.nil?
  return false if @charge_type.nil?
  charge_type_validator = EnumAttributeValidator.new('String', ["setup", "subscription", "arrears", "usage"])
  return false unless charge_type_validator.valid?(@charge_type)
  invoicing_type_validator = EnumAttributeValidator.new('String', ["Immediate", "Aggregated"])
  return false unless invoicing_type_validator.valid?(@invoicing_type)
  return false if @charge_model.nil?
  charge_model_validator = EnumAttributeValidator.new('String', ["flat", "tiered", "tiered_volume"])
  return false unless charge_model_validator.valid?(@charge_model)
  upgrade_mode_validator = EnumAttributeValidator.new('String', ["immediate", "delayed"])
  return false unless upgrade_mode_validator.valid?(@upgrade_mode)
  downgrade_mode_validator = EnumAttributeValidator.new('String', ["immediate", "delayed"])
  return false unless downgrade_mode_validator.valid?(@downgrade_mode)
  return false if @default_quantity.nil?
  return false if @valid_from.nil?
  return true
end