Class: AdvancedBilling::Allocation
- Defined in:
- lib/advanced_billing/models/allocation.rb
Overview
Allocation Model.
Instance Attribute Summary collapse
-
#accrue_charge ⇒ TrueClass | FalseClass
If the change in cost is an upgrade, this determines if the charge should accrue to the next renewal or if capture should be attempted immediately.
-
#allocation_id ⇒ Integer
The allocation unique id.
-
#charge_id ⇒ Integer
The type of credit to be created when upgrading/downgrading.
-
#component_handle ⇒ String
The handle of the component.
-
#component_id ⇒ Integer
The integer component ID for the allocation.
-
#created_at ⇒ DateTime
Timestamp indicating when this allocation was created.
-
#downgrade_credit ⇒ CreditType
The type of credit to be created when upgrading/downgrading.
-
#expires_at ⇒ DateTime
The type of credit to be created when upgrading/downgrading.
-
#initiate_dunning ⇒ TrueClass | FalseClass
If true, if the immediate component payment fails, initiate dunning for the subscription.
-
#interval ⇒ Integer
The numerical interval.
-
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this component price point, either month or day.
-
#memo ⇒ String
The memo passed when the allocation was created.
-
#payment ⇒ PaymentForAllocation
The type of credit to be created when upgrading/downgrading.
-
#previous_price_point_id ⇒ Integer
A string representing the interval unit for this component price point, either month or day.
-
#previous_quantity ⇒ Object
The allocated quantity that was in effect before this allocation was created.
-
#price_point_handle ⇒ String
The scheme used if the proration was a downgrade.
-
#price_point_id ⇒ Integer
The scheme used if the proration was a downgrade.
-
#price_point_name ⇒ String
The scheme used if the proration was a downgrade.
-
#proration_downgrade_scheme ⇒ String
The scheme used if the proration was a downgrade.
-
#proration_upgrade_scheme ⇒ String
The scheme used if the proration was an upgrade.
-
#quantity ⇒ Object
The allocated quantity set in to effect by the allocation.
-
#subscription_id ⇒ Integer
The integer subscription ID for the allocation.
-
#timestamp ⇒ DateTime
The time that the allocation was recorded, in format and UTC timezone, i.e.
-
#upgrade_charge ⇒ CreditType
The type of credit to be created when upgrading/downgrading.
-
#used_quantity ⇒ Integer
The type of credit to be created when upgrading/downgrading.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(allocation_id: SKIP, component_id: SKIP, component_handle: SKIP, subscription_id: SKIP, quantity: SKIP, previous_quantity: SKIP, memo: SKIP, timestamp: SKIP, created_at: SKIP, proration_upgrade_scheme: SKIP, proration_downgrade_scheme: SKIP, price_point_id: SKIP, price_point_name: SKIP, price_point_handle: SKIP, interval: SKIP, interval_unit: SKIP, previous_price_point_id: SKIP, accrue_charge: SKIP, initiate_dunning: SKIP, upgrade_charge: SKIP, downgrade_credit: SKIP, payment: SKIP, expires_at: SKIP, used_quantity: SKIP, charge_id: SKIP, additional_properties: {}) ⇒ Allocation
constructor
A new instance of Allocation.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_expires_at ⇒ Object
- #to_custom_timestamp ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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(allocation_id: SKIP, component_id: SKIP, component_handle: SKIP, subscription_id: SKIP, quantity: SKIP, previous_quantity: SKIP, memo: SKIP, timestamp: SKIP, created_at: SKIP, proration_upgrade_scheme: SKIP, proration_downgrade_scheme: SKIP, price_point_id: SKIP, price_point_name: SKIP, price_point_handle: SKIP, interval: SKIP, interval_unit: SKIP, previous_price_point_id: SKIP, accrue_charge: SKIP, initiate_dunning: SKIP, upgrade_charge: SKIP, downgrade_credit: SKIP, payment: SKIP, expires_at: SKIP, used_quantity: SKIP, charge_id: SKIP, additional_properties: {}) ⇒ Allocation
Returns a new instance of Allocation.
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 |
# File 'lib/advanced_billing/models/allocation.rb', line 214 def initialize(allocation_id: SKIP, component_id: SKIP, component_handle: SKIP, subscription_id: SKIP, quantity: SKIP, previous_quantity: SKIP, memo: SKIP, timestamp: SKIP, created_at: SKIP, proration_upgrade_scheme: SKIP, proration_downgrade_scheme: SKIP, price_point_id: SKIP, price_point_name: SKIP, price_point_handle: SKIP, interval: SKIP, interval_unit: SKIP, previous_price_point_id: SKIP, accrue_charge: SKIP, initiate_dunning: SKIP, upgrade_charge: SKIP, downgrade_credit: SKIP, payment: SKIP, expires_at: SKIP, used_quantity: SKIP, charge_id: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @allocation_id = allocation_id unless allocation_id == SKIP @component_id = component_id unless component_id == SKIP @component_handle = component_handle unless component_handle == 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 = unless == SKIP @created_at = created_at unless created_at == SKIP @proration_upgrade_scheme = proration_upgrade_scheme unless proration_upgrade_scheme == SKIP unless proration_downgrade_scheme == SKIP @proration_downgrade_scheme = proration_downgrade_scheme end @price_point_id = price_point_id unless price_point_id == SKIP @price_point_name = price_point_name unless price_point_name == SKIP @price_point_handle = price_point_handle unless price_point_handle == 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 @accrue_charge = accrue_charge unless accrue_charge == SKIP @initiate_dunning = initiate_dunning unless initiate_dunning == SKIP @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP @payment = payment unless payment == SKIP @expires_at = expires_at unless expires_at == SKIP @used_quantity = used_quantity unless used_quantity == SKIP @charge_id = charge_id unless charge_id == SKIP end |
Instance Attribute Details
#accrue_charge ⇒ TrueClass | FalseClass
If the change in cost is an upgrade, this determines if the charge should accrue to the next renewal or if capture should be attempted immediately.
102 103 104 |
# File 'lib/advanced_billing/models/allocation.rb', line 102 def accrue_charge @accrue_charge end |
#allocation_id ⇒ Integer
The allocation unique id
15 16 17 |
# File 'lib/advanced_billing/models/allocation.rb', line 15 def allocation_id @allocation_id end |
#charge_id ⇒ Integer
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
138 139 140 |
# File 'lib/advanced_billing/models/allocation.rb', line 138 def charge_id @charge_id end |
#component_handle ⇒ String
The handle of the component. This references a component that you have created in your Product setup
25 26 27 |
# File 'lib/advanced_billing/models/allocation.rb', line 25 def component_handle @component_handle end |
#component_id ⇒ Integer
The integer component ID for the allocation. This references a component that you have created in your Product setup
20 21 22 |
# File 'lib/advanced_billing/models/allocation.rb', line 20 def component_id @component_id end |
#created_at ⇒ DateTime
Timestamp indicating when this allocation was created
53 54 55 |
# File 'lib/advanced_billing/models/allocation.rb', line 53 def created_at @created_at end |
#downgrade_credit ⇒ CreditType
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
118 119 120 |
# File 'lib/advanced_billing/models/allocation.rb', line 118 def downgrade_credit @downgrade_credit end |
#expires_at ⇒ DateTime
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
128 129 130 |
# File 'lib/advanced_billing/models/allocation.rb', line 128 def expires_at @expires_at end |
#initiate_dunning ⇒ TrueClass | FalseClass
If true, if the immediate component payment fails, initiate dunning for the subscription. Otherwise, leave the charges on the subscription to pay for at renewal.
108 109 110 |
# File 'lib/advanced_billing/models/allocation.rb', line 108 def initiate_dunning @initiate_dunning end |
#interval ⇒ Integer
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.
85 86 87 |
# File 'lib/advanced_billing/models/allocation.rb', line 85 def interval @interval end |
#interval_unit ⇒ IntervalUnit
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.
91 92 93 |
# File 'lib/advanced_billing/models/allocation.rb', line 91 def interval_unit @interval_unit end |
#memo ⇒ String
The memo passed when the allocation was created
44 45 46 |
# File 'lib/advanced_billing/models/allocation.rb', line 44 def memo @memo end |
#payment ⇒ PaymentForAllocation
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
123 124 125 |
# File 'lib/advanced_billing/models/allocation.rb', line 123 def payment @payment end |
#previous_price_point_id ⇒ Integer
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.
97 98 99 |
# File 'lib/advanced_billing/models/allocation.rb', line 97 def previous_price_point_id @previous_price_point_id end |
#previous_quantity ⇒ Object
The allocated quantity that was in effect before this allocation was created. String for components supporting fractional quantities
40 41 42 |
# File 'lib/advanced_billing/models/allocation.rb', line 40 def previous_quantity @previous_quantity end |
#price_point_handle ⇒ String
The scheme used if the proration was a downgrade. This is only present when the allocation was created mid-period.
78 79 80 |
# File 'lib/advanced_billing/models/allocation.rb', line 78 def price_point_handle @price_point_handle end |
#price_point_id ⇒ Integer
The scheme used if the proration was a downgrade. This is only present when the allocation was created mid-period.
68 69 70 |
# File 'lib/advanced_billing/models/allocation.rb', line 68 def price_point_id @price_point_id end |
#price_point_name ⇒ String
The scheme used if the proration was a downgrade. This is only present when the allocation was created mid-period.
73 74 75 |
# File 'lib/advanced_billing/models/allocation.rb', line 73 def price_point_name @price_point_name end |
#proration_downgrade_scheme ⇒ String
The scheme used if the proration was a downgrade. This is only present when the allocation was created mid-period.
63 64 65 |
# File 'lib/advanced_billing/models/allocation.rb', line 63 def proration_downgrade_scheme @proration_downgrade_scheme end |
#proration_upgrade_scheme ⇒ String
The scheme used if the proration was an upgrade. This is only present when the allocation was created mid-period.
58 59 60 |
# File 'lib/advanced_billing/models/allocation.rb', line 58 def proration_upgrade_scheme @proration_upgrade_scheme end |
#quantity ⇒ Object
The allocated quantity set in to effect by the allocation. String for components supporting fractional quantities
35 36 37 |
# File 'lib/advanced_billing/models/allocation.rb', line 35 def quantity @quantity end |
#subscription_id ⇒ Integer
The integer subscription ID for the allocation. This references a unique subscription in your Site
30 31 32 |
# File 'lib/advanced_billing/models/allocation.rb', line 30 def subscription_id @subscription_id end |
#timestamp ⇒ DateTime
The time that the allocation was recorded, in format and UTC timezone, i.e. 2012-11-20T22:00:37Z
49 50 51 |
# File 'lib/advanced_billing/models/allocation.rb', line 49 def end |
#upgrade_charge ⇒ CreditType
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
113 114 115 |
# File 'lib/advanced_billing/models/allocation.rb', line 113 def upgrade_charge @upgrade_charge end |
#used_quantity ⇒ Integer
The type of credit to be created when upgrading/downgrading. Defaults to the component and then site setting if one is not provided.
133 134 135 |
# File 'lib/advanced_billing/models/allocation.rb', line 133 def used_quantity @used_quantity end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 343 344 345 346 347 348 349 350 |
# File 'lib/advanced_billing/models/allocation.rb', line 263 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. allocation_id = hash.key?('allocation_id') ? hash['allocation_id'] : SKIP component_id = hash.key?('component_id') ? hash['component_id'] : SKIP component_handle = hash.key?('component_handle') ? hash['component_handle'] : SKIP subscription_id = hash.key?('subscription_id') ? hash['subscription_id'] : SKIP quantity = hash.key?('quantity') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:AllocationQuantity), hash['quantity'] ) : SKIP previous_quantity = hash.key?('previous_quantity') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:AllocationPreviousQuantity), hash['previous_quantity'] ) : SKIP memo = hash.key?('memo') ? hash['memo'] : SKIP = if hash.key?('timestamp') (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp']) else SKIP end created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) else SKIP end 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 price_point_id = hash.key?('price_point_id') ? hash['price_point_id'] : SKIP price_point_name = hash.key?('price_point_name') ? hash['price_point_name'] : SKIP price_point_handle = hash.key?('price_point_handle') ? hash['price_point_handle'] : 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 accrue_charge = hash.key?('accrue_charge') ? hash['accrue_charge'] : SKIP initiate_dunning = hash.key?('initiate_dunning') ? hash['initiate_dunning'] : SKIP upgrade_charge = hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP downgrade_credit = hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP payment = PaymentForAllocation.from_hash(hash['payment']) if hash['payment'] expires_at = if hash.key?('expires_at') (DateTimeHelper.from_rfc3339(hash['expires_at']) if hash['expires_at']) else SKIP end used_quantity = hash.key?('used_quantity') ? hash['used_quantity'] : SKIP charge_id = hash.key?('charge_id') ? hash['charge_id'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. Allocation.new(allocation_id: allocation_id, component_id: component_id, component_handle: component_handle, subscription_id: subscription_id, quantity: quantity, previous_quantity: previous_quantity, memo: memo, timestamp: , created_at: created_at, proration_upgrade_scheme: proration_upgrade_scheme, proration_downgrade_scheme: proration_downgrade_scheme, price_point_id: price_point_id, price_point_name: price_point_name, price_point_handle: price_point_handle, interval: interval, interval_unit: interval_unit, previous_price_point_id: previous_price_point_id, accrue_charge: accrue_charge, initiate_dunning: initiate_dunning, upgrade_charge: upgrade_charge, downgrade_credit: downgrade_credit, payment: payment, expires_at: expires_at, used_quantity: used_quantity, charge_id: charge_id, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
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 |
# File 'lib/advanced_billing/models/allocation.rb', line 141 def self.names @_hash = {} if @_hash.nil? @_hash['allocation_id'] = 'allocation_id' @_hash['component_id'] = 'component_id' @_hash['component_handle'] = 'component_handle' @_hash['subscription_id'] = 'subscription_id' @_hash['quantity'] = 'quantity' @_hash['previous_quantity'] = 'previous_quantity' @_hash['memo'] = 'memo' @_hash['timestamp'] = 'timestamp' @_hash['created_at'] = 'created_at' @_hash['proration_upgrade_scheme'] = 'proration_upgrade_scheme' @_hash['proration_downgrade_scheme'] = 'proration_downgrade_scheme' @_hash['price_point_id'] = 'price_point_id' @_hash['price_point_name'] = 'price_point_name' @_hash['price_point_handle'] = 'price_point_handle' @_hash['interval'] = 'interval' @_hash['interval_unit'] = 'interval_unit' @_hash['previous_price_point_id'] = 'previous_price_point_id' @_hash['accrue_charge'] = 'accrue_charge' @_hash['initiate_dunning'] = 'initiate_dunning' @_hash['upgrade_charge'] = 'upgrade_charge' @_hash['downgrade_credit'] = 'downgrade_credit' @_hash['payment'] = 'payment' @_hash['expires_at'] = 'expires_at' @_hash['used_quantity'] = 'used_quantity' @_hash['charge_id'] = 'charge_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
203 204 205 206 207 208 209 210 211 212 |
# File 'lib/advanced_billing/models/allocation.rb', line 203 def self.nullables %w[ component_handle memo interval_unit upgrade_charge downgrade_credit payment ] end |
.optionals ⇒ Object
An array for optional fields
172 173 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 |
# File 'lib/advanced_billing/models/allocation.rb', line 172 def self.optionals %w[ allocation_id component_id component_handle subscription_id quantity previous_quantity memo timestamp created_at proration_upgrade_scheme proration_downgrade_scheme price_point_id price_point_name price_point_handle interval interval_unit previous_price_point_id accrue_charge initiate_dunning upgrade_charge downgrade_credit payment expires_at used_quantity charge_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
366 367 368 369 370 371 372 |
# File 'lib/advanced_billing/models/allocation.rb', line 366 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'lib/advanced_billing/models/allocation.rb', line 392 def inspect class_name = self.class.name.split('::').last "<#{class_name} allocation_id: #{@allocation_id.inspect}, component_id:"\ " #{@component_id.inspect}, component_handle: #{@component_handle.inspect}, subscription_id:"\ " #{@subscription_id.inspect}, quantity: #{@quantity.inspect}, previous_quantity:"\ " #{@previous_quantity.inspect}, memo: #{@memo.inspect}, timestamp: #{@timestamp.inspect},"\ " created_at: #{@created_at.inspect}, proration_upgrade_scheme:"\ " #{@proration_upgrade_scheme.inspect}, proration_downgrade_scheme:"\ " #{@proration_downgrade_scheme.inspect}, price_point_id: #{@price_point_id.inspect},"\ " price_point_name: #{@price_point_name.inspect}, price_point_handle:"\ " #{@price_point_handle.inspect}, interval: #{@interval.inspect}, interval_unit:"\ " #{@interval_unit.inspect}, previous_price_point_id: #{@previous_price_point_id.inspect},"\ " accrue_charge: #{@accrue_charge.inspect}, initiate_dunning: #{@initiate_dunning.inspect},"\ " upgrade_charge: #{@upgrade_charge.inspect}, downgrade_credit:"\ " #{@downgrade_credit.inspect}, payment: #{@payment.inspect}, expires_at:"\ " #{@expires_at.inspect}, used_quantity: #{@used_quantity.inspect}, charge_id:"\ " #{@charge_id.inspect}, additional_properties: #{get_additional_properties}>" end |
#to_custom_created_at ⇒ Object
356 357 358 |
# File 'lib/advanced_billing/models/allocation.rb', line 356 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_expires_at ⇒ Object
360 361 362 |
# File 'lib/advanced_billing/models/allocation.rb', line 360 def to_custom_expires_at DateTimeHelper.to_rfc3339(expires_at) end |
#to_custom_timestamp ⇒ Object
352 353 354 |
# File 'lib/advanced_billing/models/allocation.rb', line 352 def DateTimeHelper.to_rfc3339() end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/advanced_billing/models/allocation.rb', line 375 def to_s class_name = self.class.name.split('::').last "<#{class_name} allocation_id: #{@allocation_id}, component_id: #{@component_id},"\ " component_handle: #{@component_handle}, subscription_id: #{@subscription_id}, quantity:"\ " #{@quantity}, previous_quantity: #{@previous_quantity}, memo: #{@memo}, timestamp:"\ " #{@timestamp}, created_at: #{@created_at}, proration_upgrade_scheme:"\ " #{@proration_upgrade_scheme}, proration_downgrade_scheme: #{@proration_downgrade_scheme},"\ " price_point_id: #{@price_point_id}, price_point_name: #{@price_point_name},"\ " price_point_handle: #{@price_point_handle}, interval: #{@interval}, interval_unit:"\ " #{@interval_unit}, previous_price_point_id: #{@previous_price_point_id}, accrue_charge:"\ " #{@accrue_charge}, initiate_dunning: #{@initiate_dunning}, upgrade_charge:"\ " #{@upgrade_charge}, downgrade_credit: #{@downgrade_credit}, payment: #{@payment},"\ " expires_at: #{@expires_at}, used_quantity: #{@used_quantity}, charge_id: #{@charge_id},"\ " additional_properties: #{get_additional_properties}>" end |