Class: AdvancedBilling::RenewalPreviewComponent
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::RenewalPreviewComponent
- Defined in:
- lib/advanced_billing/models/renewal_preview_component.rb
Overview
RenewalPreviewComponent Model.
Instance Attribute Summary collapse
-
#component_id ⇒ Object
Either the component’s Chargify id or its handle prefixed with ‘handle:`.
-
#price_point_id ⇒ Object
Either the component price point’s Chargify id or its handle prefixed with ‘handle:`.
-
#quantity ⇒ Integer
The quantity for which you wish to preview billing.
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, quantity: SKIP, price_point_id: SKIP, additional_properties: {}) ⇒ RenewalPreviewComponent
constructor
A new instance of RenewalPreviewComponent.
Methods inherited from BaseModel
Constructor Details
#initialize(component_id: SKIP, quantity: SKIP, price_point_id: SKIP, additional_properties: {}) ⇒ RenewalPreviewComponent
Returns a new instance of RenewalPreviewComponent.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 56 def initialize(component_id: SKIP, quantity: SKIP, price_point_id: SKIP, additional_properties: {}) @component_id = component_id unless component_id == SKIP @quantity = quantity unless quantity == SKIP @price_point_id = price_point_id unless price_point_id == 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 ⇒ Object
Either the component’s Chargify id or its handle prefixed with ‘handle:`
14 15 16 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 14 def component_id @component_id end |
#price_point_id ⇒ Object
Either the component price point’s Chargify id or its handle prefixed with ‘handle:`
31 32 33 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 31 def price_point_id @price_point_id end |
#quantity ⇒ Integer
The quantity for which you wish to preview billing. This is useful if you want to preview a predicted, higher usage value than is currently present on the subscription. This quantity represents:
-
Whether or not an on/off component is enabled - use 0 for disabled or 1
for enabled
-
The desired allocated_quantity for a quantity-based component
-
The desired unit_balance for a metered component
-
The desired metric quantity for an events-based component
26 27 28 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 26 def quantity @quantity end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 69 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(:RenewalPreviewComponentComponentId), hash['component_id'] ) : SKIP quantity = hash.key?('quantity') ? hash['quantity'] : SKIP price_point_id = hash.key?('price_point_id') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:RenewalPreviewComponentPricePointId), hash['price_point_id'] ) : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. RenewalPreviewComponent.new(component_id: component_id, quantity: quantity, price_point_id: price_point_id, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['component_id'] = 'component_id' @_hash['quantity'] = 'quantity' @_hash['price_point_id'] = 'price_point_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
52 53 54 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 52 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
43 44 45 46 47 48 49 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 43 def self.optionals %w[ component_id quantity price_point_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
93 94 95 96 97 98 99 |
# File 'lib/advanced_billing/models/renewal_preview_component.rb', line 93 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |