Class: AdvancedBilling::UpdateSegment
- Defined in:
- lib/advanced_billing/models/update_segment.rb
Overview
UpdateSegment Model.
Instance Attribute Summary collapse
-
#prices ⇒ Array[CreateOrUpdateSegmentPrice]
The handle for the pricing scheme.
-
#pricing_scheme ⇒ String
The handle 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 = nil, prices = SKIP) ⇒ UpdateSegment
constructor
A new instance of UpdateSegment.
Methods inherited from BaseModel
Constructor Details
#initialize(pricing_scheme = nil, prices = SKIP) ⇒ UpdateSegment
Returns a new instance of UpdateSegment.
46 47 48 49 |
# File 'lib/advanced_billing/models/update_segment.rb', line 46 def initialize(pricing_scheme = nil, prices = SKIP) @pricing_scheme = pricing_scheme @prices = prices unless prices == SKIP end |
Instance Attribute Details
#prices ⇒ Array[CreateOrUpdateSegmentPrice]
The handle for the pricing scheme. Available options: per_unit, volume, tiered, stairstep. See [Price Bracket Rules](help.chargify.com/products/product-components.html#price-br acket-rules) for an overview of pricing schemes.
24 25 26 |
# File 'lib/advanced_billing/models/update_segment.rb', line 24 def prices @prices end |
#pricing_scheme ⇒ String
The handle for the pricing scheme. Available options: per_unit, volume, tiered, stairstep. See [Price Bracket Rules](help.chargify.com/products/product-components.html#price-br acket-rules) for an overview of pricing schemes.
17 18 19 |
# File 'lib/advanced_billing/models/update_segment.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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/advanced_billing/models/update_segment.rb', line 52 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') # Create object from extracted values. UpdateSegment.new(pricing_scheme, prices) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 |
# File 'lib/advanced_billing/models/update_segment.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['prices'] = 'prices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
42 43 44 |
# File 'lib/advanced_billing/models/update_segment.rb', line 42 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 38 39 |
# File 'lib/advanced_billing/models/update_segment.rb', line 35 def self.optionals %w[ prices ] end |