Class: AdvancedBilling::UpdateSegment
- Defined in:
- lib/advanced_billing/models/update_segment.rb
Overview
UpdateSegment Model.
Instance Attribute Summary collapse
-
#prices ⇒ Array[CreateOrUpdateSegmentPrice]
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.
Instance Method Summary collapse
-
#initialize(pricing_scheme:, prices: SKIP, additional_properties: {}) ⇒ UpdateSegment
constructor
A new instance of UpdateSegment.
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:, prices: SKIP, additional_properties: {}) ⇒ UpdateSegment
Returns a new instance of UpdateSegment.
44 45 46 47 48 49 50 51 52 |
# File 'lib/advanced_billing/models/update_segment.rb', line 44 def initialize(pricing_scheme:, prices: 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 @prices = prices unless prices == SKIP end |
Instance Attribute Details
#prices ⇒ Array[CreateOrUpdateSegmentPrice]
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
22 23 24 |
# File 'lib/advanced_billing/models/update_segment.rb', line 22 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.
16 17 18 |
# File 'lib/advanced_billing/models/update_segment.rb', line 16 def pricing_scheme @pricing_scheme end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/advanced_billing/models/update_segment.rb', line 55 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. pricing_scheme = hash.key?('pricing_scheme') ? hash['pricing_scheme'] : nil # Parameter is an array, so we need to iterate through it prices = nil unless hash['prices'].nil? prices = [] hash['prices'].each do |structure| prices << (CreateOrUpdateSegmentPrice.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. UpdateSegment.new(pricing_scheme: pricing_scheme, prices: prices, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 |
# File 'lib/advanced_billing/models/update_segment.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['prices'] = 'prices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/advanced_billing/models/update_segment.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
33 34 35 36 37 |
# File 'lib/advanced_billing/models/update_segment.rb', line 33 def self.optionals %w[ prices ] end |