Class: Bfwd::APIQuote

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

Overview

Entity containing a price quote.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ APIQuote

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
288
289
290
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
339
340
341
342
# File 'lib/bf_ruby2/models/api_quote.rb', line 210

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

end

Instance Attribute Details

#account_idObject

of the account for which a price quote is requested.“,”verbs“:



81
82
83
# File 'lib/bf_ruby2/models/api_quote.rb', line 81

def 
  @account_id
end

#changed_byObject

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



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

def changed_by
  @changed_by
end

#coupon_codesObject

list of coupon codes to consider in calculating the quote.“,”verbs“:



108
109
110
# File 'lib/bf_ruby2/models/api_quote.rb', line 108

def coupon_codes
  @coupon_codes
end

#createdObject

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



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

def created
  @created
end

#currencyObject

currency of any quoted prices — as specified by a three-character ISO 4217 currency code (i.e. USD).“,”verbs“:



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

def currency
  @currency
end

#discountObject

amount deducted from price via discounts — includes any tax upon the discounts themselves.“,”verbs“:



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

def discount
  @discount
end

#discount_excluding_taxObject

amount deducted from price via discounts — excludes any tax upon the discounts themselves.“,”verbs“:



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

def discount_excluding_tax
  @discount_excluding_tax
end

#discountsObject

list of discounts applied in calculating the quote.“,”verbs“:



87
88
89
# File 'lib/bf_ruby2/models/api_quote.rb', line 87

def discounts
  @discounts
end

#organization_idObject

of the organization in whose name the quote was generated.“,”verbs“:



111
112
113
# File 'lib/bf_ruby2/models/api_quote.rb', line 111

def organization_id
  @organization_id
end

#period_endObject

of period described in periodStart)","description":"The end date-time of the interval for which a price quote is requested.“,”verbs“:



96
97
98
# File 'lib/bf_ruby2/models/api_quote.rb', line 96

def period_end
  @period_end
end

#period_startObject

at which quote is requested)","description":"The start date-time of the interval for which a price quote is requested.“,”verbs“:



93
94
95
# File 'lib/bf_ruby2/models/api_quote.rb', line 93

def period_start
  @period_start
end

#product_idObject

of the product for which a price quote is requested.“,”verbs“:



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

def product_id
  @product_id
end

#product_nameObject

of the product for which a price quote is requested.“,”verbs“:



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

def product_name
  @product_name
end

#product_rate_plan_idObject

of the rate plan (of some product) for which a price quote is requested.“,”verbs“:



75
76
77
# File 'lib/bf_ruby2/models/api_quote.rb', line 75

def product_rate_plan_id
  @product_rate_plan_id
end

#product_rate_plan_nameObject

of the rate plan (of some product) for which a price quote is requested.“,”verbs“:



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

def product_rate_plan_name
  @product_rate_plan_name
end

#proration_enabledObject

consumption for fractions/multiples of periods is calculated as a fraction/multiple of the cost of consumption for a whole period.“,”verbs“:



102
103
104
# File 'lib/bf_ruby2/models/api_quote.rb', line 102

def proration_enabled
  @proration_enabled
end

#public_product_nameObject

name of the product for which a price quote is requested.“,”verbs“:



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

def public_product_name
  @public_product_name
end

#public_product_rate_plan_nameObject

name of the rate plan (of some product) for which a price quote is requested.“,”verbs“:



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

def public_product_rate_plan_name
  @public_product_rate_plan_name
end

#quantitiesObject

list of calculated prices for each pricing component described in the quote request.“,”verbs“:



84
85
86
# File 'lib/bf_ruby2/models/api_quote.rb', line 84

def quantities
  @quantities
end

#quote_forObject

scenario with which the quote is concerned.“,”verbs“:



90
91
92
# File 'lib/bf_ruby2/models/api_quote.rb', line 90

def quote_for
  @quote_for
end

#same_product_periodObject

migration quote whether or not the rate plans have the same duration“,”verbs“:



114
115
116
# File 'lib/bf_ruby2/models/api_quote.rb', line 114

def same_product_period
  @same_product_period
end

#subscription_idObject

of the subscription for which a price quote is requested.“,”verbs“:



78
79
80
# File 'lib/bf_ruby2/models/api_quote.rb', line 78

def subscription_id
  @subscription_id
end

#subtotalObject

cost — including tax, but excluding discounts — of all items described in the quote.“,”verbs“:



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

def subtotal
  @subtotal
end

#subtotal_excluding_taxObject

cost — excluding tax, and excluding discounts — of all items described in the quote.“,”verbs“:



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

def subtotal_excluding_tax
  @subtotal_excluding_tax
end

#taxObject

portion of this quote’s cost which is comprised of tax.“,”verbs“:



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

def tax
  @tax
end

#totalObject

cost — including tax, and with discounts (themselves including tax) applied — of all items described in the quote.“,”verbs“:



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

def total
  @total
end

#total_excluding_taxObject

cost — excluding tax, and with discounts (themselves excluding tax) applied — of all items described in the quote.“,”verbs“:



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

def total_excluding_tax
  @total_excluding_tax
end

#total_periodsObject

href="\"POST\",\"GET\"">default“:”ZERO“,”description“:”“,”verbs“:



99
100
101
# File 'lib/bf_ruby2/models/api_quote.rb', line 99

def total_periods
  @total_periods
end

#upliftObject

href="\"POST\",\"GET\"">description“:”“,”verbs“:



105
106
107
# File 'lib/bf_ruby2/models/api_quote.rb', line 105

def uplift
  @uplift
end

Class Method Details

.attribute_mapObject

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



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

def self.attribute_map
  {
    :'created' => :'created',
    :'changed_by' => :'changedBy',
    :'subtotal' => :'subtotal',
    :'subtotal_excluding_tax' => :'subtotalExcludingTax',
    :'total' => :'total',
    :'total_excluding_tax' => :'totalExcludingTax',
    :'tax' => :'tax',
    :'discount' => :'discount',
    :'discount_excluding_tax' => :'discountExcludingTax',
    :'currency' => :'currency',
    :'product_name' => :'productName',
    :'public_product_name' => :'publicProductName',
    :'product_rate_plan_name' => :'productRatePlanName',
    :'public_product_rate_plan_name' => :'publicProductRatePlanName',
    :'product_id' => :'productID',
    :'product_rate_plan_id' => :'productRatePlanID',
    :'subscription_id' => :'subscriptionID',
    :'account_id' => :'accountID',
    :'quantities' => :'quantities',
    :'discounts' => :'discounts',
    :'quote_for' => :'quoteFor',
    :'period_start' => :'periodStart',
    :'period_end' => :'periodEnd',
    :'total_periods' => :'totalPeriods',
    :'proration_enabled' => :'prorationEnabled',
    :'uplift' => :'uplift',
    :'coupon_codes' => :'couponCodes',
    :'organization_id' => :'organizationID',
    :'same_product_period' => :'sameProductPeriod'
  }
end

.swagger_typesObject

Attribute type mapping.



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

def self.swagger_types
  {
    :'created' => :'DateTime',
    :'changed_by' => :'String',
    :'subtotal' => :'Float',
    :'subtotal_excluding_tax' => :'Float',
    :'total' => :'Float',
    :'total_excluding_tax' => :'Float',
    :'tax' => :'Float',
    :'discount' => :'Float',
    :'discount_excluding_tax' => :'Float',
    :'currency' => :'String',
    :'product_name' => :'String',
    :'public_product_name' => :'String',
    :'product_rate_plan_name' => :'String',
    :'public_product_rate_plan_name' => :'String',
    :'product_id' => :'String',
    :'product_rate_plan_id' => :'String',
    :'subscription_id' => :'String',
    :'account_id' => :'String',
    :'quantities' => :'Array<APIQuoteResponseQuantity>',
    :'discounts' => :'Array<CouponWrapperResponse>',
    :'quote_for' => :'String',
    :'period_start' => :'DateTime',
    :'period_end' => :'DateTime',
    :'total_periods' => :'Float',
    :'proration_enabled' => :'BOOLEAN',
    :'uplift' => :'Float',
    :'coupon_codes' => :'Array<String>',
    :'organization_id' => :'String',
    :'same_product_period' => :'BOOLEAN'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/bf_ruby2/models/api_quote.rb', line 373

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created == o.created &&
      changed_by == o.changed_by &&
      subtotal == o.subtotal &&
      subtotal_excluding_tax == o.subtotal_excluding_tax &&
      total == o.total &&
      total_excluding_tax == o.total_excluding_tax &&
      tax == o.tax &&
      discount == o.discount &&
      discount_excluding_tax == o.discount_excluding_tax &&
      currency == o.currency &&
      product_name == o.product_name &&
      public_product_name == o.public_product_name &&
      product_rate_plan_name == o.product_rate_plan_name &&
      public_product_rate_plan_name == o.public_product_rate_plan_name &&
      product_id == o.product_id &&
      product_rate_plan_id == o.product_rate_plan_id &&
      subscription_id == o.subscription_id &&
       == o. &&
      quantities == o.quantities &&
      discounts == o.discounts &&
      quote_for == o.quote_for &&
      period_start == o.period_start &&
      period_end == o.period_end &&
      total_periods == o.total_periods &&
      proration_enabled == o.proration_enabled &&
      uplift == o.uplift &&
      coupon_codes == o.coupon_codes &&
      organization_id == o.organization_id &&
      same_product_period == o.same_product_period
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



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/bf_ruby2/models/api_quote.rb', line 443

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



509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/bf_ruby2/models/api_quote.rb', line 509

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



422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/bf_ruby2/models/api_quote.rb', line 422

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


409
410
411
# File 'lib/bf_ruby2/models/api_quote.rb', line 409

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



415
416
417
# File 'lib/bf_ruby2/models/api_quote.rb', line 415

def hash
  [created, changed_by, subtotal, subtotal_excluding_tax, total, total_excluding_tax, tax, discount, discount_excluding_tax, currency, product_name, public_product_name, product_rate_plan_name, public_product_rate_plan_name, product_id, product_rate_plan_id, subscription_id, , quantities, discounts, quote_for, period_start, period_end, total_periods, proration_enabled, uplift, coupon_codes, organization_id, same_product_period].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



346
347
348
349
# File 'lib/bf_ruby2/models/api_quote.rb', line 346

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



489
490
491
# File 'lib/bf_ruby2/models/api_quote.rb', line 489

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



495
496
497
498
499
500
501
502
503
# File 'lib/bf_ruby2/models/api_quote.rb', line 495

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



483
484
485
# File 'lib/bf_ruby2/models/api_quote.rb', line 483

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



353
354
355
356
357
358
359
# File 'lib/bf_ruby2/models/api_quote.rb', line 353

def valid?
  quote_for_validator = EnumAttributeValidator.new('String', ["InitialPeriod", "RecurringPeriod", "Upgrade", "Migration"])
  return false unless quote_for_validator.valid?(@quote_for)
  return false if @period_start.nil?
  return false if @period_end.nil?
  return true
end