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.
-
#component_id ⇒ Integer
The integer component ID for the allocation.
-
#downgrade_credit ⇒ String
The type of credit to be created if the change in cost is a downgrade.
-
#memo ⇒ String
The memo passed when the allocation was created.
-
#payment ⇒ AllocationPayment
The type of credit to be created if the change in cost is a downgrade.
-
#previous_price_point_id ⇒ Integer
The scheme used if the proration was a downgrade.
-
#previous_quantity ⇒ Integer
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 ⇒ Integer
The allocated quantity set in to effect by the allocation.
-
#subscription_id ⇒ Integer
The integer subscription ID for the allocation.
-
#timestamp ⇒ String
The time that the allocation was recorded, in format and UTC timezone, i.e.
-
#upgrade_charge ⇒ String
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
Methods inherited from BaseModel
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, price_point_id = SKIP, price_point_name = SKIP, price_point_handle = SKIP, previous_price_point_id = SKIP, accrue_charge = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, payment = SKIP) ⇒ Allocation
Returns a new instance of Allocation.
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 |
# File 'lib/advanced_billing/models/allocation.rb', line 139 def initialize(component_id = SKIP, subscription_id = SKIP, quantity = SKIP, previous_quantity = SKIP, memo = SKIP, = SKIP, proration_upgrade_scheme = SKIP, proration_downgrade_scheme = SKIP, price_point_id = SKIP, price_point_name = SKIP, price_point_handle = SKIP, previous_price_point_id = SKIP, accrue_charge = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, payment = SKIP) @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 = unless == 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 @previous_price_point_id = previous_price_point_id unless previous_price_point_id == SKIP @accrue_charge = accrue_charge unless accrue_charge == SKIP @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP @payment = payment unless payment == 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.
73 74 75 |
# File 'lib/advanced_billing/models/allocation.rb', line 73 def accrue_charge @accrue_charge end |
#component_id ⇒ Integer
The integer component ID for the allocation. This references a component that you have created in your Product setup
15 16 17 |
# File 'lib/advanced_billing/models/allocation.rb', line 15 def component_id @component_id end |
#downgrade_credit ⇒ String
The type of credit to be created if the change in cost is a downgrade.
81 82 83 |
# File 'lib/advanced_billing/models/allocation.rb', line 81 def downgrade_credit @downgrade_credit end |
#memo ⇒ String
The memo passed when the allocation was created
33 34 35 |
# File 'lib/advanced_billing/models/allocation.rb', line 33 def memo @memo end |
#payment ⇒ AllocationPayment
The type of credit to be created if the change in cost is a downgrade.
85 86 87 |
# File 'lib/advanced_billing/models/allocation.rb', line 85 def payment @payment end |
#previous_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 previous_price_point_id @previous_price_point_id end |
#previous_quantity ⇒ Integer
The allocated quantity that was in effect before this allocation was created
29 30 31 |
# File 'lib/advanced_billing/models/allocation.rb', line 29 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.
63 64 65 |
# File 'lib/advanced_billing/models/allocation.rb', line 63 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.
53 54 55 |
# File 'lib/advanced_billing/models/allocation.rb', line 53 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.
58 59 60 |
# File 'lib/advanced_billing/models/allocation.rb', line 58 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.
48 49 50 |
# File 'lib/advanced_billing/models/allocation.rb', line 48 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.
43 44 45 |
# File 'lib/advanced_billing/models/allocation.rb', line 43 def proration_upgrade_scheme @proration_upgrade_scheme end |
#quantity ⇒ Integer
The allocated quantity set in to effect by the allocation
24 25 26 |
# File 'lib/advanced_billing/models/allocation.rb', line 24 def quantity @quantity end |
#subscription_id ⇒ Integer
The integer subscription ID for the allocation. This references a unique subscription in your Site
20 21 22 |
# File 'lib/advanced_billing/models/allocation.rb', line 20 def subscription_id @subscription_id end |
#timestamp ⇒ String
The time that the allocation was recorded, in format and UTC timezone, i.e. 2012-11-20T22:00:37Z
38 39 40 |
# File 'lib/advanced_billing/models/allocation.rb', line 38 def @timestamp end |
#upgrade_charge ⇒ String
The type of charge to be created if the change in cost is an upgrade.
77 78 79 |
# File 'lib/advanced_billing/models/allocation.rb', line 77 def upgrade_charge @upgrade_charge end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/advanced_billing/models/allocation.rb', line 169 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') ? hash['quantity'] : SKIP previous_quantity = hash.key?('previous_quantity') ? hash['previous_quantity'] : SKIP memo = hash.key?('memo') ? hash['memo'] : SKIP = 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 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 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 upgrade_charge = hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP downgrade_credit = hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP payment = hash.key?('payment') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:AllocationPayment2), hash['payment'] ) : SKIP # Create object from extracted values. Allocation.new(component_id, subscription_id, quantity, previous_quantity, memo, , proration_upgrade_scheme, proration_downgrade_scheme, price_point_id, price_point_name, price_point_handle, previous_price_point_id, accrue_charge, upgrade_charge, downgrade_credit, payment) end |
.names ⇒ Object
A mapping from model property names to API property names.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/advanced_billing/models/allocation.rb', line 88 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['price_point_id'] = 'price_point_id' @_hash['price_point_name'] = 'price_point_name' @_hash['price_point_handle'] = 'price_point_handle' @_hash['previous_price_point_id'] = 'previous_price_point_id' @_hash['accrue_charge'] = 'accrue_charge' @_hash['upgrade_charge'] = 'upgrade_charge' @_hash['downgrade_credit'] = 'downgrade_credit' @_hash['payment'] = 'payment' @_hash end |
.nullables ⇒ Object
An array for nullable fields
132 133 134 135 136 137 |
# File 'lib/advanced_billing/models/allocation.rb', line 132 def self.nullables %w[ memo payment ] end |
.optionals ⇒ Object
An array for optional fields
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/advanced_billing/models/allocation.rb', line 110 def self.optionals %w[ component_id subscription_id quantity previous_quantity memo timestamp proration_upgrade_scheme proration_downgrade_scheme price_point_id price_point_name price_point_handle previous_price_point_id accrue_charge upgrade_charge downgrade_credit payment ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
223 224 225 226 227 228 229 |
# File 'lib/advanced_billing/models/allocation.rb', line 223 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |