Class: ApiReference::TieredPricingWithMinimumConfig

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/tiered_pricing_with_minimum_config.rb

Overview

Configuration for tiered pricing with minimum

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(tiers:, hide_zero_amount_tiers: SKIP, prorate: SKIP) ⇒ TieredPricingWithMinimumConfig

Returns a new instance of TieredPricingWithMinimumConfig.



48
49
50
51
52
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 48

def initialize(tiers:, hide_zero_amount_tiers: SKIP, prorate: SKIP)
  @tiers = tiers
  @hide_zero_amount_tiers = hide_zero_amount_tiers unless hide_zero_amount_tiers == SKIP
  @prorate = prorate unless prorate == SKIP
end

Instance Attribute Details

#hide_zero_amount_tiersTrueClass | FalseClass

If true, tiers with an accrued amount of 0 will not be included in the rating.

Returns:

  • (TrueClass | FalseClass)


20
21
22
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 20

def hide_zero_amount_tiers
  @hide_zero_amount_tiers
end

#prorateTrueClass | FalseClass

If true, the unit price will be prorated to the billing period

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 24

def prorate
  @prorate
end

#tiersArray[TieredPricingWithMinimumTierItem]

Tiered pricing with a minimum amount dependent on the volume tier. Tiers are defined using exclusive lower bounds.



15
16
17
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 15

def tiers
  @tiers
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
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 55

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  tiers = nil
  unless hash['tiers'].nil?
    tiers = []
    hash['tiers'].each do |structure|
      tiers << (TieredPricingWithMinimumTierItem.from_hash(structure) if structure)
    end
  end

  tiers = nil unless hash.key?('tiers')
  hide_zero_amount_tiers =
    hash.key?('hide_zero_amount_tiers') ? hash['hide_zero_amount_tiers'] : SKIP
  prorate = hash.key?('prorate') ? hash['prorate'] : SKIP

  # Create object from extracted values.
  TieredPricingWithMinimumConfig.new(tiers: tiers,
                                     hide_zero_amount_tiers: hide_zero_amount_tiers,
                                     prorate: prorate)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['tiers'] = 'tiers'
  @_hash['hide_zero_amount_tiers'] = 'hide_zero_amount_tiers'
  @_hash['prorate'] = 'prorate'
  @_hash
end

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 36

def self.optionals
  %w[
    hide_zero_amount_tiers
    prorate
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



87
88
89
90
91
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 87

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} tiers: #{@tiers.inspect}, hide_zero_amount_tiers:"\
  " #{@hide_zero_amount_tiers.inspect}, prorate: #{@prorate.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



80
81
82
83
84
# File 'lib/api_reference/models/tiered_pricing_with_minimum_config.rb', line 80

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} tiers: #{@tiers}, hide_zero_amount_tiers: #{@hide_zero_amount_tiers},"\
  " prorate: #{@prorate}>"
end