Class: AdvancedBilling::AllocationPreviewItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/allocation_preview_item.rb

Overview

AllocationPreviewItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(component_id: SKIP, subscription_id: SKIP, quantity: SKIP, previous_quantity: SKIP, memo: SKIP, timestamp: SKIP, proration_upgrade_scheme: SKIP, proration_downgrade_scheme: SKIP, accrue_charge: SKIP, upgrade_charge: SKIP, downgrade_credit: SKIP, price_point_id: SKIP, interval: SKIP, interval_unit: SKIP, previous_price_point_id: SKIP, price_point_handle: SKIP, price_point_name: SKIP, component_handle: SKIP, additional_properties: {}) ⇒ AllocationPreviewItem

Returns a new instance of AllocationPreviewItem.



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
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 160

def initialize(component_id: SKIP, subscription_id: SKIP, quantity: SKIP,
               previous_quantity: SKIP, memo: SKIP, timestamp: SKIP,
               proration_upgrade_scheme: SKIP,
               proration_downgrade_scheme: SKIP, accrue_charge: SKIP,
               upgrade_charge: SKIP, downgrade_credit: SKIP,
               price_point_id: SKIP, interval: SKIP, interval_unit: SKIP,
               previous_price_point_id: SKIP, price_point_handle: SKIP,
               price_point_name: SKIP, component_handle: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @component_id = component_id unless component_id == SKIP
  @subscription_id = subscription_id unless subscription_id == SKIP
  @quantity = quantity unless quantity == SKIP
  @previous_quantity = previous_quantity unless previous_quantity == SKIP
  @memo = memo unless memo == SKIP
  @timestamp = timestamp unless timestamp == SKIP
  @proration_upgrade_scheme = proration_upgrade_scheme unless proration_upgrade_scheme == SKIP
  unless proration_downgrade_scheme == SKIP
    @proration_downgrade_scheme =
      proration_downgrade_scheme
  end
  @accrue_charge = accrue_charge unless accrue_charge == SKIP
  @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP
  @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP
  @price_point_id = price_point_id unless price_point_id == SKIP
  @interval = interval unless interval == SKIP
  @interval_unit = interval_unit unless interval_unit == SKIP
  @previous_price_point_id = previous_price_point_id unless previous_price_point_id == SKIP
  @price_point_handle = price_point_handle unless price_point_handle == SKIP
  @price_point_name = price_point_name unless price_point_name == SKIP
  @component_handle = component_handle unless component_handle == SKIP
end

Instance Attribute Details

#accrue_chargeTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


46
47
48
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 46

def accrue_charge
  @accrue_charge
end

#component_handleString

A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.

Returns:

  • (String)


98
99
100
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 98

def component_handle
  @component_handle
end

#component_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 14

def component_id
  @component_id
end

#downgrade_creditCreditType

The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.

Returns:



56
57
58
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 56

def downgrade_credit
  @downgrade_credit
end

#intervalInteger

The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this component price point would renew every 30 days. This property is only available for sites with Multifrequency enabled.

Returns:

  • (Integer)


68
69
70
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 68

def interval
  @interval
end

#interval_unitIntervalUnit

A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.

Returns:



74
75
76
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 74

def interval_unit
  @interval_unit
end

#memoString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 30

def memo
  @memo
end

#previous_price_point_idInteger

A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.

Returns:

  • (Integer)


80
81
82
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 80

def previous_price_point_id
  @previous_price_point_id
end

#previous_quantityObject

TODO: Write general description for this method

Returns:

  • (Object)


26
27
28
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 26

def previous_quantity
  @previous_quantity
end

#price_point_handleString

A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.

Returns:

  • (String)


86
87
88
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 86

def price_point_handle
  @price_point_handle
end

#price_point_idInteger

The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.

Returns:

  • (Integer)


61
62
63
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 61

def price_point_id
  @price_point_id
end

#price_point_nameString

A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.

Returns:

  • (String)


92
93
94
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 92

def price_point_name
  @price_point_name
end

#proration_downgrade_schemeString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 42

def proration_downgrade_scheme
  @proration_downgrade_scheme
end

#proration_upgrade_schemeString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 38

def proration_upgrade_scheme
  @proration_upgrade_scheme
end

#quantityObject

TODO: Write general description for this method

Returns:

  • (Object)


22
23
24
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 22

def quantity
  @quantity
end

#subscription_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 18

def subscription_id
  @subscription_id
end

#timestampString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 34

def timestamp
  @timestamp
end

#upgrade_chargeCreditType

The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.

Returns:



51
52
53
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 51

def upgrade_charge
  @upgrade_charge
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 198

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  component_id = hash.key?('component_id') ? hash['component_id'] : SKIP
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : SKIP
  quantity = hash.key?('quantity') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:AllocationPreviewItemQuantity), hash['quantity']
  ) : SKIP
  previous_quantity = hash.key?('previous_quantity') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:AllocationPreviewItemPreviousQuantity), hash['previous_quantity']
  ) : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  timestamp = hash.key?('timestamp') ? hash['timestamp'] : SKIP
  proration_upgrade_scheme =
    hash.key?('proration_upgrade_scheme') ? hash['proration_upgrade_scheme'] : SKIP
  proration_downgrade_scheme =
    hash.key?('proration_downgrade_scheme') ? hash['proration_downgrade_scheme'] : SKIP
  accrue_charge = hash.key?('accrue_charge') ? hash['accrue_charge'] : SKIP
  upgrade_charge =
    hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP
  downgrade_credit =
    hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP
  price_point_id =
    hash.key?('price_point_id') ? hash['price_point_id'] : SKIP
  interval = hash.key?('interval') ? hash['interval'] : SKIP
  interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : SKIP
  previous_price_point_id =
    hash.key?('previous_price_point_id') ? hash['previous_price_point_id'] : SKIP
  price_point_handle =
    hash.key?('price_point_handle') ? hash['price_point_handle'] : SKIP
  price_point_name =
    hash.key?('price_point_name') ? hash['price_point_name'] : SKIP
  component_handle =
    hash.key?('component_handle') ? hash['component_handle'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  AllocationPreviewItem.new(component_id: component_id,
                            subscription_id: subscription_id,
                            quantity: quantity,
                            previous_quantity: previous_quantity,
                            memo: memo,
                            timestamp: timestamp,
                            proration_upgrade_scheme: proration_upgrade_scheme,
                            proration_downgrade_scheme: proration_downgrade_scheme,
                            accrue_charge: accrue_charge,
                            upgrade_charge: upgrade_charge,
                            downgrade_credit: downgrade_credit,
                            price_point_id: price_point_id,
                            interval: interval,
                            interval_unit: interval_unit,
                            previous_price_point_id: previous_price_point_id,
                            price_point_handle: price_point_handle,
                            price_point_name: price_point_name,
                            component_handle: component_handle,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 101

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['component_id'] = 'component_id'
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['quantity'] = 'quantity'
  @_hash['previous_quantity'] = 'previous_quantity'
  @_hash['memo'] = 'memo'
  @_hash['timestamp'] = 'timestamp'
  @_hash['proration_upgrade_scheme'] = 'proration_upgrade_scheme'
  @_hash['proration_downgrade_scheme'] = 'proration_downgrade_scheme'
  @_hash['accrue_charge'] = 'accrue_charge'
  @_hash['upgrade_charge'] = 'upgrade_charge'
  @_hash['downgrade_credit'] = 'downgrade_credit'
  @_hash['price_point_id'] = 'price_point_id'
  @_hash['interval'] = 'interval'
  @_hash['interval_unit'] = 'interval_unit'
  @_hash['previous_price_point_id'] = 'previous_price_point_id'
  @_hash['price_point_handle'] = 'price_point_handle'
  @_hash['price_point_name'] = 'price_point_name'
  @_hash['component_handle'] = 'component_handle'
  @_hash
end

.nullablesObject

An array for nullable fields



149
150
151
152
153
154
155
156
157
158
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 149

def self.nullables
  %w[
    memo
    timestamp
    upgrade_charge
    downgrade_credit
    interval_unit
    component_handle
  ]
end

.optionalsObject

An array for optional fields



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 125

def self.optionals
  %w[
    component_id
    subscription_id
    quantity
    previous_quantity
    memo
    timestamp
    proration_upgrade_scheme
    proration_downgrade_scheme
    accrue_charge
    upgrade_charge
    downgrade_credit
    price_point_id
    interval
    interval_unit
    previous_price_point_id
    price_point_handle
    price_point_name
    component_handle
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



262
263
264
265
266
267
268
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 262

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 286

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} component_id: #{@component_id.inspect}, subscription_id:"\
  " #{@subscription_id.inspect}, quantity: #{@quantity.inspect}, previous_quantity:"\
  " #{@previous_quantity.inspect}, memo: #{@memo.inspect}, timestamp: #{@timestamp.inspect},"\
  " proration_upgrade_scheme: #{@proration_upgrade_scheme.inspect},"\
  " proration_downgrade_scheme: #{@proration_downgrade_scheme.inspect}, accrue_charge:"\
  " #{@accrue_charge.inspect}, upgrade_charge: #{@upgrade_charge.inspect}, downgrade_credit:"\
  " #{@downgrade_credit.inspect}, price_point_id: #{@price_point_id.inspect}, interval:"\
  " #{@interval.inspect}, interval_unit: #{@interval_unit.inspect}, previous_price_point_id:"\
  " #{@previous_price_point_id.inspect}, price_point_handle: #{@price_point_handle.inspect},"\
  " price_point_name: #{@price_point_name.inspect}, component_handle:"\
  " #{@component_handle.inspect}, additional_properties: #{get_additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 271

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} component_id: #{@component_id}, subscription_id: #{@subscription_id},"\
  " quantity: #{@quantity}, previous_quantity: #{@previous_quantity}, memo: #{@memo},"\
  " timestamp: #{@timestamp}, proration_upgrade_scheme: #{@proration_upgrade_scheme},"\
  " proration_downgrade_scheme: #{@proration_downgrade_scheme}, accrue_charge:"\
  " #{@accrue_charge}, upgrade_charge: #{@upgrade_charge}, downgrade_credit:"\
  " #{@downgrade_credit}, price_point_id: #{@price_point_id}, interval: #{@interval},"\
  " interval_unit: #{@interval_unit}, previous_price_point_id: #{@previous_price_point_id},"\
  " price_point_handle: #{@price_point_handle}, price_point_name: #{@price_point_name},"\
  " component_handle: #{@component_handle}, additional_properties:"\
  " #{get_additional_properties}>"
end