Class: AdvancedBilling::SubscriptionGroupComponentCustomPrice
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::SubscriptionGroupComponentCustomPrice
- Defined in:
- lib/advanced_billing/models/subscription_group_component_custom_price.rb
Overview
Used in place of ‘price_point_id` to define a custom price point unique to the subscription. You still need to provide `component_id`.
Instance Attribute Summary collapse
-
#overage_pricing ⇒ Array[ComponentCustomPrice]
The identifier for the pricing scheme.
-
#prices ⇒ Array[Price]
The identifier for the pricing scheme.
-
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme.
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(pricing_scheme: SKIP, prices: SKIP, overage_pricing: SKIP, additional_properties: {}) ⇒ SubscriptionGroupComponentCustomPrice
constructor
A new instance of SubscriptionGroupComponentCustomPrice.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(pricing_scheme: SKIP, prices: SKIP, overage_pricing: SKIP, additional_properties: {}) ⇒ SubscriptionGroupComponentCustomPrice
Returns a new instance of SubscriptionGroupComponentCustomPrice.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 54 def initialize(pricing_scheme: SKIP, prices: SKIP, overage_pricing: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP @prices = prices unless prices == SKIP @overage_pricing = overage_pricing unless overage_pricing == SKIP end |
Instance Attribute Details
#overage_pricing ⇒ Array[ComponentCustomPrice]
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
29 30 31 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 29 def overage_pricing @overage_pricing end |
#prices ⇒ Array[Price]
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
23 24 25 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 23 def prices @prices end |
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
17 18 19 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 17 def pricing_scheme @pricing_scheme end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 67 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. pricing_scheme = hash.key?('pricing_scheme') ? hash['pricing_scheme'] : SKIP # Parameter is an array, so we need to iterate through it prices = nil unless hash['prices'].nil? prices = [] hash['prices'].each do |structure| prices << (Price.from_hash(structure) if structure) end end prices = SKIP unless hash.key?('prices') # Parameter is an array, so we need to iterate through it overage_pricing = nil unless hash['overage_pricing'].nil? overage_pricing = [] hash['overage_pricing'].each do |structure| overage_pricing << (ComponentCustomPrice.from_hash(structure) if structure) end end overage_pricing = SKIP unless hash.key?('overage_pricing') # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. SubscriptionGroupComponentCustomPrice.new(pricing_scheme: pricing_scheme, prices: prices, overage_pricing: overage_pricing, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
32 33 34 35 36 37 38 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 32 def self.names @_hash = {} if @_hash.nil? @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['prices'] = 'prices' @_hash['overage_pricing'] = 'overage_pricing' @_hash end |
.nullables ⇒ Object
An array for nullable fields
50 51 52 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 50 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
41 42 43 44 45 46 47 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 41 def self.optionals %w[ pricing_scheme prices overage_pricing ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
106 107 108 109 110 111 112 |
# File 'lib/advanced_billing/models/subscription_group_component_custom_price.rb', line 106 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |