Class: AdvancedBilling::ComponentCostData
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ComponentCostData
- Defined in:
- lib/advanced_billing/models/component_cost_data.rb
Overview
ComponentCostData Model.
Instance Attribute Summary collapse
-
#amount ⇒ String
TODO: Write general description for this method.
-
#component_code_id ⇒ Integer
TODO: Write general description for this method.
-
#price_point_id ⇒ Integer
TODO: Write general description for this method.
-
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme.
-
#product_id ⇒ Integer
TODO: Write general description for this method.
-
#quantity ⇒ String
TODO: Write general description for this method.
-
#tiers ⇒ Array[ComponentCostDataRateTier]
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(component_code_id: SKIP, price_point_id: SKIP, product_id: SKIP, quantity: SKIP, amount: SKIP, pricing_scheme: SKIP, tiers: SKIP, additional_properties: {}) ⇒ ComponentCostData
constructor
A new instance of ComponentCostData.
Methods inherited from BaseModel
Constructor Details
#initialize(component_code_id: SKIP, price_point_id: SKIP, product_id: SKIP, quantity: SKIP, amount: SKIP, pricing_scheme: SKIP, tiers: SKIP, additional_properties: {}) ⇒ ComponentCostData
Returns a new instance of ComponentCostData.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 77 def initialize(component_code_id: SKIP, price_point_id: SKIP, product_id: SKIP, quantity: SKIP, amount: SKIP, pricing_scheme: SKIP, tiers: SKIP, additional_properties: {}) @component_code_id = component_code_id unless component_code_id == SKIP @price_point_id = price_point_id unless price_point_id == SKIP @product_id = product_id unless product_id == SKIP @quantity = quantity unless quantity == SKIP @amount = amount unless amount == SKIP @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP @tiers = tiers unless tiers == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#amount ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 30 def amount @amount end |
#component_code_id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 14 def component_code_id @component_code_id end |
#price_point_id ⇒ Integer
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 18 def price_point_id @price_point_id 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.
36 37 38 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 36 def pricing_scheme @pricing_scheme end |
#product_id ⇒ Integer
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 22 def product_id @product_id end |
#quantity ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 26 def quantity @quantity end |
#tiers ⇒ Array[ComponentCostDataRateTier]
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
42 43 44 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 42 def tiers @tiers end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 95 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. component_code_id = hash.key?('component_code_id') ? hash['component_code_id'] : SKIP price_point_id = hash.key?('price_point_id') ? hash['price_point_id'] : SKIP product_id = hash.key?('product_id') ? hash['product_id'] : SKIP quantity = hash.key?('quantity') ? hash['quantity'] : SKIP amount = hash.key?('amount') ? hash['amount'] : SKIP pricing_scheme = hash.key?('pricing_scheme') ? hash['pricing_scheme'] : SKIP # Parameter is an array, so we need to iterate through it tiers = nil unless hash['tiers'].nil? tiers = [] hash['tiers'].each do |structure| tiers << (ComponentCostDataRateTier.from_hash(structure) if structure) end end tiers = SKIP unless hash.key?('tiers') # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. ComponentCostData.new(component_code_id: component_code_id, price_point_id: price_point_id, product_id: product_id, quantity: quantity, amount: amount, pricing_scheme: pricing_scheme, tiers: tiers, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 45 def self.names @_hash = {} if @_hash.nil? @_hash['component_code_id'] = 'component_code_id' @_hash['price_point_id'] = 'price_point_id' @_hash['product_id'] = 'product_id' @_hash['quantity'] = 'quantity' @_hash['amount'] = 'amount' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['tiers'] = 'tiers' @_hash end |
.nullables ⇒ Object
An array for nullable fields
71 72 73 74 75 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 71 def self.nullables %w[ component_code_id ] end |
.optionals ⇒ Object
An array for optional fields
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 58 def self.optionals %w[ component_code_id price_point_id product_id quantity amount pricing_scheme tiers ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
135 136 137 138 139 140 141 |
# File 'lib/advanced_billing/models/component_cost_data.rb', line 135 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |