Class: AdvancedBilling::UpdateSubscriptionComponent
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::UpdateSubscriptionComponent
- Defined in:
- lib/advanced_billing/models/update_subscription_component.rb
Overview
UpdateSubscriptionComponent Model.
Instance Attribute Summary collapse
-
#component_id ⇒ Integer
TODO: Write general description for this method.
-
#custom_price ⇒ ComponentCustomPrice
Create or update custom pricing unique to the 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
-
#initialize(component_id: SKIP, custom_price: SKIP, additional_properties: {}) ⇒ UpdateSubscriptionComponent
constructor
A new instance of UpdateSubscriptionComponent.
Methods inherited from BaseModel
Constructor Details
#initialize(component_id: SKIP, custom_price: SKIP, additional_properties: {}) ⇒ UpdateSubscriptionComponent
Returns a new instance of UpdateSubscriptionComponent.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/advanced_billing/models/update_subscription_component.rb', line 42 def initialize(component_id: SKIP, custom_price: SKIP, additional_properties: {}) @component_id = component_id unless component_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
#component_id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/update_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`.
19 20 21 |
# File 'lib/advanced_billing/models/update_subscription_component.rb', line 19 def custom_price @custom_price end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/advanced_billing/models/update_subscription_component.rb', line 54 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. component_id = hash.key?('component_id') ? hash['component_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. UpdateSubscriptionComponent.new(component_id: component_id, custom_price: custom_price, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
22 23 24 25 26 27 |
# File 'lib/advanced_billing/models/update_subscription_component.rb', line 22 def self.names @_hash = {} if @_hash.nil? @_hash['component_id'] = 'component_id' @_hash['custom_price'] = 'custom_price' @_hash end |
.nullables ⇒ Object
An array for nullable fields
38 39 40 |
# File 'lib/advanced_billing/models/update_subscription_component.rb', line 38 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
30 31 32 33 34 35 |
# File 'lib/advanced_billing/models/update_subscription_component.rb', line 30 def self.optionals %w[ component_id custom_price ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
72 73 74 75 76 77 78 |
# File 'lib/advanced_billing/models/update_subscription_component.rb', line 72 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |