Class: AdvancedBilling::CreateSubscriptionComponent
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreateSubscriptionComponent
- Defined in:
- lib/advanced_billing/models/create_subscription_component.rb
Overview
CreateSubscriptionComponent Model.
Instance Attribute Summary collapse
-
#allocated_quantity ⇒ Object
Used for quantity based components.
-
#component_id ⇒ Object
TODO: Write general description for this method.
-
#custom_price ⇒ ComponentCustomPrice
Create or update custom pricing unique to the subscription.
-
#enabled ⇒ TrueClass | FalseClass
Used for on/off components only.
-
#price_point_id ⇒ Object
Deprecated.
-
#quantity ⇒ Integer
Deprecated.
-
#unit_balance ⇒ Integer
Used for metered and events based components.
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(component_id: SKIP, enabled: SKIP, unit_balance: SKIP, allocated_quantity: SKIP, quantity: SKIP, price_point_id: SKIP, custom_price: SKIP, additional_properties: {}) ⇒ CreateSubscriptionComponent
constructor
A new instance of CreateSubscriptionComponent.
Methods inherited from BaseModel
Constructor Details
#initialize(component_id: SKIP, enabled: SKIP, unit_balance: SKIP, allocated_quantity: SKIP, quantity: SKIP, price_point_id: SKIP, custom_price: SKIP, additional_properties: {}) ⇒ CreateSubscriptionComponent
Returns a new instance of CreateSubscriptionComponent.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 72 def initialize(component_id: SKIP, enabled: SKIP, unit_balance: SKIP, allocated_quantity: SKIP, quantity: SKIP, price_point_id: SKIP, custom_price: SKIP, additional_properties: {}) @component_id = component_id unless component_id == SKIP @enabled = enabled unless enabled == SKIP @unit_balance = unit_balance unless unit_balance == SKIP @allocated_quantity = allocated_quantity unless allocated_quantity == SKIP @quantity = quantity unless quantity == SKIP @price_point_id = price_point_id unless price_point_id == SKIP @custom_price = custom_price unless custom_price == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#allocated_quantity ⇒ Object
Used for quantity based components.
26 27 28 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 26 def allocated_quantity @allocated_quantity end |
#component_id ⇒ Object
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 14 def component_id @component_id end |
#custom_price ⇒ ComponentCustomPrice
Create or update custom pricing unique to the subscription. Used in place of ‘price_point_id`.
39 40 41 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 39 def custom_price @custom_price end |
#enabled ⇒ TrueClass | FalseClass
Used for on/off components only.
18 19 20 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 18 def enabled @enabled end |
#price_point_id ⇒ Object
Deprecated. Use ‘allocated_quantity` instead.
34 35 36 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 34 def price_point_id @price_point_id end |
#quantity ⇒ Integer
Deprecated. Use ‘allocated_quantity` instead.
30 31 32 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 30 def quantity @quantity end |
#unit_balance ⇒ Integer
Used for metered and events based components.
22 23 24 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 22 def unit_balance @unit_balance end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 91 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. component_id = hash.key?('component_id') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:CreateSubscriptionComponentComponentId), hash['component_id'] ) : SKIP enabled = hash.key?('enabled') ? hash['enabled'] : SKIP unit_balance = hash.key?('unit_balance') ? hash['unit_balance'] : SKIP allocated_quantity = hash.key?('allocated_quantity') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:CreateSubscriptionComponentAllocatedQuantity), hash['allocated_quantity'] ) : SKIP quantity = hash.key?('quantity') ? hash['quantity'] : SKIP price_point_id = hash.key?('price_point_id') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:CreateSubscriptionComponentPricePointId), hash['price_point_id'] ) : SKIP custom_price = ComponentCustomPrice.from_hash(hash['custom_price']) if hash['custom_price'] # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. CreateSubscriptionComponent.new(component_id: component_id, enabled: enabled, unit_balance: unit_balance, allocated_quantity: allocated_quantity, quantity: quantity, price_point_id: price_point_id, custom_price: custom_price, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['component_id'] = 'component_id' @_hash['enabled'] = 'enabled' @_hash['unit_balance'] = 'unit_balance' @_hash['allocated_quantity'] = 'allocated_quantity' @_hash['quantity'] = 'quantity' @_hash['price_point_id'] = 'price_point_id' @_hash['custom_price'] = 'custom_price' @_hash end |
.nullables ⇒ Object
An array for nullable fields
68 69 70 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 68 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 55 def self.optionals %w[ component_id enabled unit_balance allocated_quantity quantity price_point_id custom_price ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
125 126 127 128 129 130 131 |
# File 'lib/advanced_billing/models/create_subscription_component.rb', line 125 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |