Class: SmplkitGeneratedClient::App::SubscriptionPreviewAttributes

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb

Overview

Projected totals and per-change breakdown for a hypothetical change.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ SubscriptionPreviewAttributes

Initializes the object

Parameters:

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

    Model attributes in the form of hash



115
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
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
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 115

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::SubscriptionPreviewAttributes` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::SubscriptionPreviewAttributes`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'projected_subtotal_cents')
    self.projected_subtotal_cents = attributes[:'projected_subtotal_cents']
  else
    self.projected_subtotal_cents = nil
  end

  if attributes.key?(:'projected_discount_pct')
    self.projected_discount_pct = attributes[:'projected_discount_pct']
  else
    self.projected_discount_pct = nil
  end

  if attributes.key?(:'projected_discount_source')
    self.projected_discount_source = attributes[:'projected_discount_source']
  else
    self.projected_discount_source = nil
  end

  if attributes.key?(:'projected_discount_amount_cents')
    self.projected_discount_amount_cents = attributes[:'projected_discount_amount_cents']
  else
    self.projected_discount_amount_cents = nil
  end

  if attributes.key?(:'projected_total_cents')
    self.projected_total_cents = attributes[:'projected_total_cents']
  else
    self.projected_total_cents = nil
  end

  if attributes.key?(:'projected_next_tier')
    self.projected_next_tier = attributes[:'projected_next_tier']
  end

  if attributes.key?(:'changes')
    if (value = attributes[:'changes']).is_a?(Array)
      self.changes = value
    end
  else
    self.changes = nil
  end

  if attributes.key?(:'total_charge_today_cents')
    self.total_charge_today_cents = attributes[:'total_charge_today_cents']
  else
    self.total_charge_today_cents = nil
  end

  if attributes.key?(:'next_invoice_total_cents')
    self.next_invoice_total_cents = attributes[:'next_invoice_total_cents']
  else
    self.next_invoice_total_cents = nil
  end
end

Instance Attribute Details

#changesObject

Per-product breakdown of changes the desired state would produce. Products that would remain unchanged are omitted.



37
38
39
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 37

def changes
  @changes
end

#next_invoice_total_centsObject

Projected total of the next monthly invoice in cents, after all scheduled changes have taken effect.



43
44
45
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 43

def next_invoice_total_cents
  @next_invoice_total_cents
end

#projected_discount_amount_centsObject

Projected discount amount in cents after the change.



29
30
31
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 29

def projected_discount_amount_cents
  @projected_discount_amount_cents
end

#projected_discount_pctObject

Projected discount percentage that will apply after the change.



23
24
25
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 23

def projected_discount_pct
  @projected_discount_pct
end

#projected_discount_sourceObject

‘VOLUME` when the projected discount comes from the multi-product schedule; `OVERRIDE` when an administrator’s discount applies.



26
27
28
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 26

def projected_discount_source
  @projected_discount_source
end

#projected_next_tierObject

Returns the value of attribute projected_next_tier.



34
35
36
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 34

def projected_next_tier
  @projected_next_tier
end

#projected_subtotal_centsObject

Projected sum of item monthly list prices after the change.



20
21
22
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 20

def projected_subtotal_cents
  @projected_subtotal_cents
end

#projected_total_centsObject

Projected final monthly total in cents after the change.



32
33
34
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 32

def projected_total_cents
  @projected_total_cents
end

#total_charge_today_centsObject

Total amount that would be charged at confirmation time, in cents. The sum of ‘prorated_charge_today_cents` across `IMMEDIATE` changes.



40
41
42
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 40

def total_charge_today_cents
  @total_charge_today_cents
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



83
84
85
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 83

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



88
89
90
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 88

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 68

def self.attribute_map
  {
    :'projected_subtotal_cents' => :'projected_subtotal_cents',
    :'projected_discount_pct' => :'projected_discount_pct',
    :'projected_discount_source' => :'projected_discount_source',
    :'projected_discount_amount_cents' => :'projected_discount_amount_cents',
    :'projected_total_cents' => :'projected_total_cents',
    :'projected_next_tier' => :'projected_next_tier',
    :'changes' => :'changes',
    :'total_charge_today_cents' => :'total_charge_today_cents',
    :'next_invoice_total_cents' => :'next_invoice_total_cents'
  }
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



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 352

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



108
109
110
111
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 108

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 93

def self.openapi_types
  {
    :'projected_subtotal_cents' => :'Integer',
    :'projected_discount_pct' => :'Integer',
    :'projected_discount_source' => :'String',
    :'projected_discount_amount_cents' => :'Integer',
    :'projected_total_cents' => :'Integer',
    :'projected_next_tier' => :'NextTierResponse',
    :'changes' => :'Array<SubscriptionChangeProjection>',
    :'total_charge_today_cents' => :'Integer',
    :'next_invoice_total_cents' => :'Integer'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 323

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      projected_subtotal_cents == o.projected_subtotal_cents &&
      projected_discount_pct == o.projected_discount_pct &&
      projected_discount_source == o.projected_discount_source &&
      projected_discount_amount_cents == o.projected_discount_amount_cents &&
      projected_total_cents == o.projected_total_cents &&
      projected_next_tier == o.projected_next_tier &&
      changes == o.changes &&
      total_charge_today_cents == o.total_charge_today_cents &&
      next_invoice_total_cents == o.next_invoice_total_cents
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


339
340
341
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 339

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



345
346
347
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 345

def hash
  [projected_subtotal_cents, projected_discount_pct, projected_discount_source, projected_discount_amount_cents, projected_total_cents, projected_next_tier, changes, total_charge_today_cents, next_invoice_total_cents].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 186

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @projected_subtotal_cents.nil?
    invalid_properties.push('invalid value for "projected_subtotal_cents", projected_subtotal_cents cannot be nil.')
  end

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

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

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

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

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

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

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 374

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/subscription_preview_attributes.rb', line 226

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @projected_subtotal_cents.nil?
  return false if @projected_discount_pct.nil?
  return false if @projected_discount_source.nil?
  projected_discount_source_validator = EnumAttributeValidator.new('String', ["VOLUME", "OVERRIDE"])
  return false unless projected_discount_source_validator.valid?(@projected_discount_source)
  return false if @projected_discount_amount_cents.nil?
  return false if @projected_total_cents.nil?
  return false if @changes.nil?
  return false if @total_charge_today_cents.nil?
  return false if @next_invoice_total_cents.nil?
  true
end