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



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

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



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

def 
  @account_id
end

#changed_byObject

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



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

def changed_by
  @changed_by
end

#coupon_codesObject

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



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

def coupon_codes
  @coupon_codes
end

#createdObject

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



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

def created
  @created
end

#currencyObject

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



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

def currency
  @currency
end

#discountObject

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



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

def discount
  @discount
end

#discount_excluding_taxObject

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



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

def discount_excluding_tax
  @discount_excluding_tax
end

#discountsObject

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



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

def discounts
  @discounts
end

#organization_idObject

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



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

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



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

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



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

def period_start
  @period_start
end

#product_idObject

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



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

def product_id
  @product_id
end

#product_nameObject

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



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

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



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

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



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

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



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

def proration_enabled
  @proration_enabled
end

#public_product_nameObject

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



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

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



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

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



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

def quantities
  @quantities
end

#quote_forObject

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



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

def quote_for
  @quote_for
end

#same_product_periodObject

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



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

def same_product_period
  @same_product_period
end

#subscription_idObject

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



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

def subscription_id
  @subscription_id
end

#subtotalObject

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



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

def subtotal
  @subtotal
end

#subtotal_excluding_taxObject

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



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

def subtotal_excluding_tax
  @subtotal_excluding_tax
end

#taxObject

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



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

def tax
  @tax
end

#totalObject

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



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

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



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

def total_excluding_tax
  @total_excluding_tax
end

#total_periodsObject

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



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

def total_periods
  @total_periods
end

#upliftObject

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



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

def uplift
  @uplift
end

Class Method Details

.attribute_mapObject

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



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

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.



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

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



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

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



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

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



506
507
508
509
510
511
512
513
514
515
516
517
518
# File 'lib/bf_ruby2/models/api_quote.rb', line 506

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



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

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


406
407
408
# File 'lib/bf_ruby2/models/api_quote.rb', line 406

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



412
413
414
# File 'lib/bf_ruby2/models/api_quote.rb', line 412

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



335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/bf_ruby2/models/api_quote.rb', line 335

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

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



486
487
488
# File 'lib/bf_ruby2/models/api_quote.rb', line 486

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



492
493
494
495
496
497
498
499
500
# File 'lib/bf_ruby2/models/api_quote.rb', line 492

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



480
481
482
# File 'lib/bf_ruby2/models/api_quote.rb', line 480

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



350
351
352
353
354
355
356
# File 'lib/bf_ruby2/models/api_quote.rb', line 350

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