Class: ApiReference::TieredPackagePricingWithMinimumConfig1

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

Overview

Configuration for tiered_package_with_minimum 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:) ⇒ TieredPackagePricingWithMinimumConfig1

Returns a new instance of TieredPackagePricingWithMinimumConfig1.



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

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

Instance Attribute Details

#package_sizeFloat

Apply tiered pricing after rounding up the quantity to the package size. Tiers are defined using exclusive lower bounds.

Returns:

  • (Float)


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

def package_size
  @package_size
end

#tiersArray[TieredPackageWithMinimumTierItem]

Apply tiered pricing after rounding up the quantity to the package size. Tiers are defined using exclusive lower bounds.



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

def tiers
  @tiers
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/api_reference/models/tiered_package_pricing_with_minimum_config1.rb', line 46

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 << (TieredPackageWithMinimumTierItem.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.
  TieredPackagePricingWithMinimumConfig1.new(tiers: tiers,
                                             package_size: package_size)
end

.namesObject

A mapping from model property names to API property names.



23
24
25
26
27
28
# File 'lib/api_reference/models/tiered_package_pricing_with_minimum_config1.rb', line 23

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

.nullablesObject

An array for nullable fields



36
37
38
# File 'lib/api_reference/models/tiered_package_pricing_with_minimum_config1.rb', line 36

def self.nullables
  []
end

.optionalsObject

An array for optional fields



31
32
33
# File 'lib/api_reference/models/tiered_package_pricing_with_minimum_config1.rb', line 31

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/api_reference/models/tiered_package_pricing_with_minimum_config1.rb', line 69

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

  return false unless value.instance_of? Hash

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



100
101
102
103
# File 'lib/api_reference/models/tiered_package_pricing_with_minimum_config1.rb', line 100

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.



94
95
96
97
# File 'lib/api_reference/models/tiered_package_pricing_with_minimum_config1.rb', line 94

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