Class: AdvancedBilling::CreateAllocation
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreateAllocation
- Defined in:
- lib/advanced_billing/models/create_allocation.rb
Overview
CreateAllocation 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.
-
#component_id ⇒ Integer
(required for the multiple allocations endpoint) The id associated with the component for which the allocation is being made.
-
#downgrade_credit ⇒ CreditType1
The type of credit to be created if the change in cost is a downgrade.
-
#memo ⇒ String
A memo to record along with the allocation.
-
#price_point_id ⇒ Object
Price point that the allocation should be charged at.
-
#proration_downgrade_scheme ⇒ String
The scheme used if the proration is a downgrade.
-
#proration_upgrade_scheme ⇒ String
The scheme used if the proration is an upgrade.
-
#quantity ⇒ Float
The allocated quantity to which to set the line-items allocated quantity.
-
#upgrade_charge ⇒ CreditType1
The type of charge to be created if the change in cost is an upgrade.
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(quantity = nil, component_id = SKIP, memo = SKIP, proration_downgrade_scheme = SKIP, proration_upgrade_scheme = SKIP, accrue_charge = SKIP, downgrade_credit = SKIP, upgrade_charge = SKIP, price_point_id = SKIP) ⇒ CreateAllocation
constructor
A new instance of CreateAllocation.
Methods inherited from BaseModel
Constructor Details
#initialize(quantity = nil, component_id = SKIP, memo = SKIP, proration_downgrade_scheme = SKIP, proration_upgrade_scheme = SKIP, accrue_charge = SKIP, downgrade_credit = SKIP, upgrade_charge = SKIP, price_point_id = SKIP) ⇒ CreateAllocation
Returns a new instance of CreateAllocation.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 96 def initialize(quantity = nil, component_id = SKIP, memo = SKIP, proration_downgrade_scheme = SKIP, proration_upgrade_scheme = SKIP, accrue_charge = SKIP, downgrade_credit = SKIP, upgrade_charge = SKIP, price_point_id = SKIP) @quantity = quantity @component_id = component_id unless component_id == SKIP @memo = memo unless memo == SKIP unless proration_downgrade_scheme == SKIP @proration_downgrade_scheme = proration_downgrade_scheme end @proration_upgrade_scheme = proration_upgrade_scheme unless proration_upgrade_scheme == SKIP @accrue_charge = accrue_charge unless accrue_charge == SKIP @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP @price_point_id = price_point_id unless price_point_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. Defaults to the site setting if one is not provided.
42 43 44 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 42 def accrue_charge @accrue_charge end |
#component_id ⇒ Integer
(required for the multiple allocations endpoint) The id associated with the component for which the allocation is being made
22 23 24 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 22 def component_id @component_id end |
#downgrade_credit ⇒ CreditType1
The type of credit to be created if the change in cost is a downgrade. Defaults to the component and then site setting if one is not provided.
47 48 49 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 47 def downgrade_credit @downgrade_credit end |
#memo ⇒ String
A memo to record along with the allocation
26 27 28 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 26 def memo @memo end |
#price_point_id ⇒ Object
Price point that the allocation should be charged at. Accepts either the price point’s id (integer) or handle (string). When not specified, the default price point will be used.
58 59 60 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 58 def price_point_id @price_point_id end |
#proration_downgrade_scheme ⇒ String
The scheme used if the proration is a downgrade. Defaults to the site setting if one is not provided.
31 32 33 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 31 def proration_downgrade_scheme @proration_downgrade_scheme end |
#proration_upgrade_scheme ⇒ String
The scheme used if the proration is an upgrade. Defaults to the site setting if one is not provided.
36 37 38 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 36 def proration_upgrade_scheme @proration_upgrade_scheme end |
#quantity ⇒ Float
The allocated quantity to which to set the line-items allocated quantity. By default, this is an integer. If decimal allocations are enabled for the component, it will be a decimal number. For On/Off components, use 1for on and 0 for off.
17 18 19 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 17 def quantity @quantity end |
#upgrade_charge ⇒ CreditType1
The type of charge to be created if the change in cost is an upgrade. Defaults to the component and then site setting if one is not provided.
52 53 54 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 52 def upgrade_charge @upgrade_charge end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 116 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. quantity = hash.key?('quantity') ? hash['quantity'] : nil component_id = hash.key?('component_id') ? hash['component_id'] : SKIP memo = hash.key?('memo') ? hash['memo'] : SKIP proration_downgrade_scheme = hash.key?('proration_downgrade_scheme') ? hash['proration_downgrade_scheme'] : SKIP proration_upgrade_scheme = hash.key?('proration_upgrade_scheme') ? hash['proration_upgrade_scheme'] : SKIP accrue_charge = hash.key?('accrue_charge') ? hash['accrue_charge'] : SKIP downgrade_credit = hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP upgrade_charge = hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP price_point_id = hash.key?('price_point_id') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:CreateAllocationPricePointId), hash['price_point_id'] ) : SKIP # Create object from extracted values. CreateAllocation.new(quantity, component_id, memo, proration_downgrade_scheme, proration_upgrade_scheme, accrue_charge, downgrade_credit, upgrade_charge, price_point_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 61 def self.names @_hash = {} if @_hash.nil? @_hash['quantity'] = 'quantity' @_hash['component_id'] = 'component_id' @_hash['memo'] = 'memo' @_hash['proration_downgrade_scheme'] = 'proration_downgrade_scheme' @_hash['proration_upgrade_scheme'] = 'proration_upgrade_scheme' @_hash['accrue_charge'] = 'accrue_charge' @_hash['downgrade_credit'] = 'downgrade_credit' @_hash['upgrade_charge'] = 'upgrade_charge' @_hash['price_point_id'] = 'price_point_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
90 91 92 93 94 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 90 def self.nullables %w[ price_point_id ] end |
.optionals ⇒ Object
An array for optional fields
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 76 def self.optionals %w[ component_id memo proration_downgrade_scheme proration_upgrade_scheme accrue_charge downgrade_credit upgrade_charge price_point_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/advanced_billing/models/create_allocation.rb', line 150 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.quantity, ->(val) { val.instance_of? Float }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['quantity'], ->(val) { val.instance_of? Float }) end |