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.
-
#interval ⇒ Integer
The numerical interval.
-
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this component price point, either month or day.
-
#name ⇒ String
TODO: Write general description for this method.
-
#prices ⇒ Array[Price]
A string representing the interval unit for this component price point, either month or day.
-
#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(name: SKIP, handle: SKIP, pricing_scheme: SKIP, interval: SKIP, interval_unit: SKIP, prices: SKIP, additional_properties: {}) ⇒ ComponentPricePointItem
constructor
A new instance of ComponentPricePointItem.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(name: SKIP, handle: SKIP, pricing_scheme: SKIP, interval: SKIP, interval_unit: SKIP, prices: SKIP, additional_properties: {}) ⇒ ComponentPricePointItem
Returns a new instance of ComponentPricePointItem.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 76 def initialize(name: SKIP, handle: SKIP, pricing_scheme: SKIP, interval: SKIP, interval_unit: SKIP, prices: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @name = name unless name == SKIP @handle = handle unless handle == SKIP @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP @interval = interval unless interval == SKIP @interval_unit = interval_unit unless interval_unit == 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 |
#interval ⇒ Integer
The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this component price point would renew every 30 days. This property is only available for sites with Multifrequency enabled.
31 32 33 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 31 def interval @interval end |
#interval_unit ⇒ IntervalUnit
A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.
37 38 39 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 37 def interval_unit @interval_unit 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]
A string representing the interval unit for this component price point, either month or day. This property is only available for sites with Multifrequency enabled.
43 44 45 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 43 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.
24 25 26 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 24 def pricing_scheme @pricing_scheme end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
93 94 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 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 93 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 interval = hash.key?('interval') ? hash['interval'] : SKIP interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : 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') # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. ComponentPricePointItem.new(name: name, handle: handle, pricing_scheme: pricing_scheme, interval: interval, interval_unit: interval_unit, prices: prices, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 46 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['interval'] = 'interval' @_hash['interval_unit'] = 'interval_unit' @_hash['prices'] = 'prices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
70 71 72 73 74 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 70 def self.nullables %w[ interval_unit ] end |
.optionals ⇒ Object
An array for optional fields
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 58 def self.optionals %w[ name handle pricing_scheme interval interval_unit prices ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
129 130 131 132 133 134 135 |
# File 'lib/advanced_billing/models/component_price_point_item.rb', line 129 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |