Class: ApiReference::TieredPackagePricingConfig1

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

Overview

Configuration for tiered_package pricing

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:, package_size:) ⇒ TieredPackagePricingConfig1

Returns a new instance of TieredPackagePricingConfig1.



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

def initialize(tiers:, package_size:)
  @tiers = tiers
  @package_size = package_size
end

Instance Attribute Details

#package_sizeString

Apply tiered pricing after rounding up the quantity to the package size. Tiers are defined using exclusive lower bounds. The tier bounds are defined based on the total quantity rather than the number of packages, so they must be multiples of the package size.

Returns:

  • (String)


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

def package_size
  @package_size
end

#tiersArray[TieredPackageTierItem]

Apply tiered pricing after rounding up the quantity to the package size. Tiers are defined using exclusive lower bounds. The tier bounds are defined based on the total quantity rather than the number of packages, so they must be multiples of the package size.

Returns:



17
18
19
# File 'lib/api_reference/models/tiered_package_pricing_config1.rb', line 17

def tiers
  @tiers
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/api_reference/models/tiered_package_pricing_config1.rb', line 50

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 << (TieredPackageTierItem.from_hash(structure) if structure)
    end
  end

  tiers = nil unless hash.key?('tiers')
  package_size = hash.key?('package_size') ? hash['package_size'] : nil

  # Create object from extracted values.
  TieredPackagePricingConfig1.new(tiers: tiers,
                                  package_size: package_size)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/api_reference/models/tiered_package_pricing_config1.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
# File 'lib/api_reference/models/tiered_package_pricing_config1.rb', line 35

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/api_reference/models/tiered_package_pricing_config1.rb', line 73

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.tiers,
                            ->(val) { TieredPackageTierItem.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
        APIHelper.valid_type?(value.package_size,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['tiers'],
                          ->(val) { TieredPackageTierItem.validate(val) },
                          is_model_hash: true,
                          is_inner_model_hash: true) and
      APIHelper.valid_type?(value['package_size'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



104
105
106
107
# File 'lib/api_reference/models/tiered_package_pricing_config1.rb', line 104

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

#to_sObject

Provides a human-readable string representation of the object.



98
99
100
101
# File 'lib/api_reference/models/tiered_package_pricing_config1.rb', line 98

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