Class: AdvancedBilling::SubscriptionComponent
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::SubscriptionComponent
- Defined in:
- lib/advanced_billing/models/subscription_component.rb
Overview
SubscriptionComponent Model.
Instance Attribute Summary collapse
-
#allocated_quantity ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription.
-
#allow_fractional_quantities ⇒ TrueClass | FalseClass
For Quantity-based components: The current allocation for the component on the given subscription.
-
#archived_at ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#component_handle ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#component_id ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription.
-
#created_at ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#currency ⇒ String
(for on/off components) indicates if the component is enabled for the subscription.
-
#description ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#display_on_hosted_page ⇒ TrueClass | FalseClass
An optional object, will be returned if provided ‘include=subscription` query param.
-
#downgrade_credit ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#enabled ⇒ TrueClass | FalseClass
(for on/off components) indicates if the component is enabled for the subscription.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#kind ⇒ String
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#price_point_handle ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#price_point_id ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription.
-
#price_point_name ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#price_point_type ⇒ Object
For Quantity-based components: The current allocation for the component on the given subscription.
-
#pricing_scheme ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#product_family_handle ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#product_family_id ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription.
-
#recurring ⇒ TrueClass | FalseClass
For Quantity-based components: The current allocation for the component on the given subscription.
-
#subscription ⇒ SubscriptionComponentSubscription
An optional object, will be returned if provided ‘include=subscription` query param.
-
#subscription_id ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription.
-
#unit_balance ⇒ Integer
(for on/off components) indicates if the component is enabled for the subscription.
-
#unit_name ⇒ String
TODO: Write general description for this method.
-
#updated_at ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#upgrade_charge ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription.
-
#use_site_exchange_rate ⇒ TrueClass | FalseClass
For Quantity-based components: The current allocation for the component on the given subscription.
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(id = SKIP, name = SKIP, kind = SKIP, unit_name = SKIP, enabled = SKIP, unit_balance = SKIP, currency = SKIP, allocated_quantity = SKIP, pricing_scheme = SKIP, component_id = SKIP, component_handle = SKIP, subscription_id = SKIP, recurring = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, archived_at = SKIP, price_point_id = SKIP, price_point_handle = SKIP, price_point_type = SKIP, price_point_name = SKIP, product_family_id = SKIP, product_family_handle = SKIP, created_at = SKIP, updated_at = SKIP, use_site_exchange_rate = SKIP, description = SKIP, allow_fractional_quantities = SKIP, subscription = SKIP, display_on_hosted_page = SKIP) ⇒ SubscriptionComponent
Returns a new instance of SubscriptionComponent.
259 260 261 262 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 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 259 def initialize(id = SKIP, name = SKIP, kind = SKIP, unit_name = SKIP, enabled = SKIP, unit_balance = SKIP, currency = SKIP, allocated_quantity = SKIP, pricing_scheme = SKIP, component_id = SKIP, component_handle = SKIP, subscription_id = SKIP, recurring = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, archived_at = SKIP, price_point_id = SKIP, price_point_handle = SKIP, price_point_type = SKIP, price_point_name = SKIP, product_family_id = SKIP, product_family_handle = SKIP, created_at = SKIP, updated_at = SKIP, use_site_exchange_rate = SKIP, description = SKIP, allow_fractional_quantities = SKIP, subscription = SKIP, display_on_hosted_page = SKIP) @id = id unless id == SKIP @name = name unless name == SKIP @kind = kind unless kind == SKIP @unit_name = unit_name unless unit_name == SKIP @enabled = enabled unless enabled == SKIP @unit_balance = unit_balance unless unit_balance == SKIP @currency = currency unless currency == SKIP @allocated_quantity = allocated_quantity unless allocated_quantity == SKIP @pricing_scheme = pricing_scheme unless pricing_scheme == 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 @recurring = recurring unless recurring == SKIP @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP @archived_at = archived_at unless archived_at == SKIP @price_point_id = price_point_id unless price_point_id == SKIP @price_point_handle = price_point_handle unless price_point_handle == SKIP @price_point_type = price_point_type unless price_point_type == SKIP @price_point_name = price_point_name unless price_point_name == SKIP @product_family_id = product_family_id unless product_family_id == SKIP @product_family_handle = product_family_handle unless product_family_handle == SKIP @created_at = created_at unless created_at == SKIP @updated_at = updated_at unless updated_at == SKIP @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP @description = description unless description == SKIP unless allow_fractional_quantities == SKIP @allow_fractional_quantities = allow_fractional_quantities end @subscription = subscription unless subscription == SKIP @display_on_hosted_page = display_on_hosted_page unless display_on_hosted_page == SKIP end |
Instance Attribute Details
#allocated_quantity ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
47 48 49 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 47 def allocated_quantity @allocated_quantity end |
#allow_fractional_quantities ⇒ TrueClass | FalseClass
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
161 162 163 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 161 def allow_fractional_quantities @allow_fractional_quantities end |
#archived_at ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
95 96 97 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 95 def archived_at @archived_at end |
#component_handle ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
65 66 67 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 65 def component_handle @component_handle end |
#component_id ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
59 60 61 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 59 def component_id @component_id end |
#created_at ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
137 138 139 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 137 def created_at @created_at end |
#currency ⇒ String
(for on/off components) indicates if the component is enabled for the subscription
41 42 43 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 41 def currency @currency end |
#description ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
155 156 157 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 155 def description @description end |
#display_on_hosted_page ⇒ TrueClass | FalseClass
An optional object, will be returned if provided ‘include=subscription` query param.
171 172 173 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 171 def display_on_hosted_page @display_on_hosted_page end |
#downgrade_credit ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
89 90 91 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 89 def downgrade_credit @downgrade_credit end |
#enabled ⇒ TrueClass | FalseClass
(for on/off components) indicates if the component is enabled for the subscription
31 32 33 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 31 def enabled @enabled end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 14 def id @id end |
#kind ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 22 def kind @kind end |
#name ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 18 def name @name end |
#price_point_handle ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
107 108 109 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 107 def price_point_handle @price_point_handle end |
#price_point_id ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
101 102 103 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 101 def price_point_id @price_point_id end |
#price_point_name ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
119 120 121 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 119 def price_point_name @price_point_name end |
#price_point_type ⇒ Object
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
113 114 115 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 113 def price_point_type @price_point_type end |
#pricing_scheme ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
53 54 55 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 53 def pricing_scheme @pricing_scheme end |
#product_family_handle ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
131 132 133 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 131 def product_family_handle @product_family_handle end |
#product_family_id ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
125 126 127 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 125 def product_family_id @product_family_id end |
#recurring ⇒ TrueClass | FalseClass
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
77 78 79 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 77 def recurring @recurring end |
#subscription ⇒ SubscriptionComponentSubscription
An optional object, will be returned if provided ‘include=subscription` query param.
166 167 168 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 166 def subscription @subscription end |
#subscription_id ⇒ Integer
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
71 72 73 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 71 def subscription_id @subscription_id end |
#unit_balance ⇒ Integer
(for on/off components) indicates if the component is enabled for the subscription
36 37 38 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 36 def unit_balance @unit_balance end |
#unit_name ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 26 def unit_name @unit_name end |
#updated_at ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
143 144 145 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 143 def updated_at @updated_at end |
#upgrade_charge ⇒ String
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
83 84 85 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 83 def upgrade_charge @upgrade_charge end |
#use_site_exchange_rate ⇒ TrueClass | FalseClass
For Quantity-based components: The current allocation for the component on the given subscription. For On/Off components: Use 1 for on. Use 0 for off.
149 150 151 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 149 def use_site_exchange_rate @use_site_exchange_rate end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 307 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP kind = hash.key?('kind') ? hash['kind'] : SKIP unit_name = hash.key?('unit_name') ? hash['unit_name'] : SKIP enabled = hash.key?('enabled') ? hash['enabled'] : SKIP unit_balance = hash.key?('unit_balance') ? hash['unit_balance'] : SKIP currency = hash.key?('currency') ? hash['currency'] : SKIP allocated_quantity = hash.key?('allocated_quantity') ? hash['allocated_quantity'] : SKIP pricing_scheme = hash.key?('pricing_scheme') ? hash['pricing_scheme'] : 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 recurring = hash.key?('recurring') ? hash['recurring'] : SKIP upgrade_charge = hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP downgrade_credit = hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP archived_at = hash.key?('archived_at') ? hash['archived_at'] : SKIP price_point_id = hash.key?('price_point_id') ? hash['price_point_id'] : SKIP price_point_handle = hash.key?('price_point_handle') ? hash['price_point_handle'] : SKIP price_point_type = hash.key?('price_point_type') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionComponentPricePointType), hash['price_point_type'] ) : SKIP price_point_name = hash.key?('price_point_name') ? hash['price_point_name'] : SKIP product_family_id = hash.key?('product_family_id') ? hash['product_family_id'] : SKIP product_family_handle = hash.key?('product_family_handle') ? hash['product_family_handle'] : SKIP created_at = hash.key?('created_at') ? hash['created_at'] : SKIP updated_at = hash.key?('updated_at') ? hash['updated_at'] : SKIP use_site_exchange_rate = hash.key?('use_site_exchange_rate') ? hash['use_site_exchange_rate'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP allow_fractional_quantities = hash.key?('allow_fractional_quantities') ? hash['allow_fractional_quantities'] : SKIP subscription = SubscriptionComponentSubscription.from_hash(hash['subscription']) if hash['subscription'] display_on_hosted_page = hash.key?('display_on_hosted_page') ? hash['display_on_hosted_page'] : SKIP # Create object from extracted values. SubscriptionComponent.new(id, name, kind, unit_name, enabled, unit_balance, currency, allocated_quantity, pricing_scheme, component_id, component_handle, subscription_id, recurring, upgrade_charge, downgrade_credit, archived_at, price_point_id, price_point_handle, price_point_type, price_point_name, product_family_id, product_family_handle, created_at, updated_at, use_site_exchange_rate, description, allow_fractional_quantities, subscription, display_on_hosted_page) end |
.names ⇒ Object
A mapping from model property names to API property names.
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 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 174 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['kind'] = 'kind' @_hash['unit_name'] = 'unit_name' @_hash['enabled'] = 'enabled' @_hash['unit_balance'] = 'unit_balance' @_hash['currency'] = 'currency' @_hash['allocated_quantity'] = 'allocated_quantity' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['component_id'] = 'component_id' @_hash['component_handle'] = 'component_handle' @_hash['subscription_id'] = 'subscription_id' @_hash['recurring'] = 'recurring' @_hash['upgrade_charge'] = 'upgrade_charge' @_hash['downgrade_credit'] = 'downgrade_credit' @_hash['archived_at'] = 'archived_at' @_hash['price_point_id'] = 'price_point_id' @_hash['price_point_handle'] = 'price_point_handle' @_hash['price_point_type'] = 'price_point_type' @_hash['price_point_name'] = 'price_point_name' @_hash['product_family_id'] = 'product_family_id' @_hash['product_family_handle'] = 'product_family_handle' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['use_site_exchange_rate'] = 'use_site_exchange_rate' @_hash['description'] = 'description' @_hash['allow_fractional_quantities'] = 'allow_fractional_quantities' @_hash['subscription'] = 'subscription' @_hash['display_on_hosted_page'] = 'display_on_hosted_page' @_hash end |
.nullables ⇒ Object
An array for nullable fields
244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 244 def self.nullables %w[ pricing_scheme component_handle upgrade_charge downgrade_credit archived_at price_point_id price_point_handle price_point_name use_site_exchange_rate description ] end |
.optionals ⇒ Object
An array for optional fields
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 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 209 def self.optionals %w[ id name kind unit_name enabled unit_balance currency allocated_quantity pricing_scheme component_id component_handle subscription_id recurring upgrade_charge downgrade_credit archived_at price_point_id price_point_handle price_point_type price_point_name product_family_id product_family_handle created_at updated_at use_site_exchange_rate description allow_fractional_quantities subscription display_on_hosted_page ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
392 393 394 395 396 397 398 |
# File 'lib/advanced_billing/models/subscription_component.rb', line 392 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |