Class: AdvancedBilling::ComponentPricePointItem
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ComponentPricePointItem
- Defined in:
- lib/advanced_billing/models/component_price_point_item.rb
Overview
ComponentPricePointItem Model.
Instance Attribute Summary collapse
-
#handle ⇒ String
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#prices ⇒ Array[Price]
TODO: Write general description for this method.
-
#pricing_scheme ⇒ String
TODO: Write general description for this method.
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(name = SKIP, handle = SKIP, pricing_scheme = SKIP, prices = SKIP) ⇒ ComponentPricePointItem
constructor
A new instance of ComponentPricePointItem.
Methods inherited from BaseModel
Constructor Details
#initialize(name = SKIP, handle = SKIP, pricing_scheme = SKIP, prices = SKIP) ⇒ ComponentPricePointItem
Returns a new instance of ComponentPricePointItem.
53 54 55 56 57 58 59 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 53 def initialize(name = SKIP, handle = SKIP, pricing_scheme = SKIP, prices = SKIP) @name = name unless name == SKIP @handle = handle unless handle == SKIP @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP @prices = prices unless prices == SKIP end |
Instance Attribute Details
#handle ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 18 def handle @handle end |
#name ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 14 def name @name end |
#prices ⇒ Array[Price]
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 26 def prices @prices end |
#pricing_scheme ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 22 def pricing_scheme @pricing_scheme end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : SKIP handle = hash.key?('handle') ? hash['handle'] : SKIP 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') # Create object from extracted values. ComponentPricePointItem.new(name, handle, pricing_scheme, prices) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['prices'] = 'prices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 49 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 45 46 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 39 def self.optionals %w[ name handle pricing_scheme prices ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
90 91 92 93 94 95 96 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 90 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |