Class: AdvancedBilling::UpdateSegment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/update_segment.rb

Overview

UpdateSegment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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

#pricesArray[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.

Returns:



24
25
26
# File 'lib/advanced_billing/models/update_segment.rb', line 24

def prices
  @prices
end

#pricing_schemeString

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.

Returns:

  • (String)


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

.namesObject

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

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/advanced_billing/models/update_segment.rb', line 42

def self.nullables
  []
end

.optionalsObject

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