Class: WalmartApIs::PackageDimensions1
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- WalmartApIs::PackageDimensions1
- Defined in:
- lib/walmart_ap_is/models/package_dimensions1.rb
Overview
Physical dimensions of a shipped package. All numeric values are non-negative; unit enums avoid the unit-ambiguity bug that bit gmp-orders-mono PayloadUtil pre-2024.
Instance Attribute Summary collapse
-
#dimension_unit ⇒ DimensionUnit
TODO: Write general description for this method.
-
#height ⇒ Float
TODO: Write general description for this method.
-
#length ⇒ Float
TODO: Write general description for this method.
-
#weight ⇒ Float
TODO: Write general description for this method.
-
#weight_unit ⇒ WeightUnit
TODO: Write general description for this method.
-
#width ⇒ Float
TODO: Write general description for this method.
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(length: SKIP, width: SKIP, height: SKIP, dimension_unit: DimensionUnit::IN, weight: SKIP, weight_unit: WeightUnit::LB, additional_properties: nil) ⇒ PackageDimensions1
constructor
A new instance of PackageDimensions1.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(length: SKIP, width: SKIP, height: SKIP, dimension_unit: DimensionUnit::IN, weight: SKIP, weight_unit: WeightUnit::LB, additional_properties: nil) ⇒ PackageDimensions1
Returns a new instance of PackageDimensions1.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 67 def initialize(length: SKIP, width: SKIP, height: SKIP, dimension_unit: DimensionUnit::IN, weight: SKIP, weight_unit: WeightUnit::LB, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @length = length unless length == SKIP @width = width unless width == SKIP @height = height unless height == SKIP @dimension_unit = dimension_unit unless dimension_unit == SKIP @weight = weight unless weight == SKIP @weight_unit = weight_unit unless weight_unit == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#dimension_unit ⇒ DimensionUnit
TODO: Write general description for this method
28 29 30 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 28 def dimension_unit @dimension_unit end |
#height ⇒ Float
TODO: Write general description for this method
24 25 26 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 24 def height @height end |
#length ⇒ Float
TODO: Write general description for this method
16 17 18 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 16 def length @length end |
#weight ⇒ Float
TODO: Write general description for this method
32 33 34 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 32 def weight @weight end |
#weight_unit ⇒ WeightUnit
TODO: Write general description for this method
36 37 38 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 36 def weight_unit @weight_unit end |
#width ⇒ Float
TODO: Write general description for this method
20 21 22 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 20 def width @width end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 83 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. length = hash.key?('length') ? hash['length'] : SKIP width = hash.key?('width') ? hash['width'] : SKIP height = hash.key?('height') ? hash['height'] : SKIP dimension_unit = hash['dimensionUnit'] ||= DimensionUnit::IN weight = hash.key?('weight') ? hash['weight'] : SKIP weight_unit = hash['weightUnit'] ||= WeightUnit::LB # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. PackageDimensions1.new(length: length, width: width, height: height, dimension_unit: dimension_unit, weight: weight, weight_unit: weight_unit, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['length'] = 'length' @_hash['width'] = 'width' @_hash['height'] = 'height' @_hash['dimension_unit'] = 'dimensionUnit' @_hash['weight'] = 'weight' @_hash['weight_unit'] = 'weightUnit' @_hash end |
.nullables ⇒ Object
An array for nullable fields
63 64 65 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 63 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 51 def self.optionals %w[ length width height dimension_unit weight weight_unit ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
120 121 122 123 124 125 126 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 120 def inspect class_name = self.class.name.split('::').last "<#{class_name} length: #{@length.inspect}, width: #{@width.inspect}, height:"\ " #{@height.inspect}, dimension_unit: #{@dimension_unit.inspect}, weight:"\ " #{@weight.inspect}, weight_unit: #{@weight_unit.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
112 113 114 115 116 117 |
# File 'lib/walmart_ap_is/models/package_dimensions1.rb', line 112 def to_s class_name = self.class.name.split('::').last "<#{class_name} length: #{@length}, width: #{@width}, height: #{@height}, dimension_unit:"\ " #{@dimension_unit}, weight: #{@weight}, weight_unit: #{@weight_unit},"\ " additional_properties: #{@additional_properties}>" end |