Class: UspsApi::LabelsPackageDescription1

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/labels_package_description1.rb

Overview

Package Definitions

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(weight_uom: WeightUom::LB, weight: SKIP, dimensions_uom: DimensionsUom::ENUM_IN, length: SKIP, height: SKIP, width: SKIP, girth: SKIP, has_nonstandard_characteristics: false, additional_properties: nil) ⇒ LabelsPackageDescription1

Returns a new instance of LabelsPackageDescription1.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/usps_api/models/labels_package_description1.rb', line 113

def initialize(weight_uom: WeightUom::LB, weight: SKIP,
               dimensions_uom: DimensionsUom::ENUM_IN, length: SKIP,
               height: SKIP, width: SKIP, girth: SKIP,
               has_nonstandard_characteristics: false,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @weight_uom = weight_uom unless weight_uom == SKIP
  @weight = weight unless weight == SKIP
  @dimensions_uom = dimensions_uom unless dimensions_uom == SKIP
  @length = length unless length == SKIP
  @height = height unless height == SKIP
  @width = width unless width == SKIP
  @girth = girth unless girth == SKIP
  unless has_nonstandard_characteristics == SKIP
    @has_nonstandard_characteristics =
      has_nonstandard_characteristics
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#dimensions_uomDimensionsUom

Dimensions unit of measure

  • in - Inches

Returns:



25
26
27
# File 'lib/usps_api/models/labels_package_description1.rb', line 25

def dimensions_uom
  @dimensions_uom
end

#girthFloat

The girth of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a non- rectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non- rectangular packages.

Returns:

  • (Float)


69
70
71
# File 'lib/usps_api/models/labels_package_description1.rb', line 69

def girth
  @girth
end

#has_nonstandard_characteristicsTrueClass | FalseClass

Package is nonstandard. Nonstandard packages include cylindrical tubes and rolls, certain high-density items, cartons containing more than 24 ounces of liquids in one or more glass containers, cartons containing 1 gallon or more of liquid in metal or plastic containers, and items in [201.7.6.2](pe.usps.com/text/dmm300/201.htm#7.6.2).

Returns:

  • (TrueClass | FalseClass)


77
78
79
# File 'lib/usps_api/models/labels_package_description1.rb', line 77

def has_nonstandard_characteristics
  @has_nonstandard_characteristics
end

#heightFloat

The height of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. Length, Width, and Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. Girth is required only for a non-rectangular package in addition to Length, Width, and Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages.

Returns:

  • (Float)


47
48
49
# File 'lib/usps_api/models/labels_package_description1.rb', line 47

def height
  @height
end

#lengthFloat

The length of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. Length, Width, and Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. Girth is required only for a non-rectangular package in addition to Length, Width, and Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non-rectangular packages.

Returns:

  • (Float)


36
37
38
# File 'lib/usps_api/models/labels_package_description1.rb', line 36

def length
  @length
end

#weightFloat

The package weight, in weightUOM (Unit Of Measure). Items must weigh 70 pounds (1120 ounces) or less.

Returns:

  • (Float)


20
21
22
# File 'lib/usps_api/models/labels_package_description1.rb', line 20

def weight
  @weight
end

#weight_uomWeightUom

Weight Unit of Measurement

* lb - Pounds

Returns:



15
16
17
# File 'lib/usps_api/models/labels_package_description1.rb', line 15

def weight_uom
  @weight_uom
end

#widthFloat

The width of the container, in dimensionsUOM. If partial dimensions are provided, an error response will return. Length, Width, and Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. Girth is required only for a non-rectangular package in addition to Length, Width, and Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for non- rectangular packages.

Returns:

  • (Float)


58
59
60
# File 'lib/usps_api/models/labels_package_description1.rb', line 58

def width
  @width
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/usps_api/models/labels_package_description1.rb', line 136

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  weight_uom = hash['weightUOM'] ||= WeightUom::LB
  weight = hash.key?('weight') ? hash['weight'] : SKIP
  dimensions_uom = hash['dimensionsUOM'] ||= DimensionsUom::ENUM_IN
  length = hash.key?('length') ? hash['length'] : SKIP
  height = hash.key?('height') ? hash['height'] : SKIP
  width = hash.key?('width') ? hash['width'] : SKIP
  girth = hash.key?('girth') ? hash['girth'] : SKIP
  has_nonstandard_characteristics =
    hash['hasNonstandardCharacteristics'] ||= false

  # 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.
  LabelsPackageDescription1.new(weight_uom: weight_uom,
                                weight: weight,
                                dimensions_uom: dimensions_uom,
                                length: length,
                                height: height,
                                width: width,
                                girth: girth,
                                has_nonstandard_characteristics: has_nonstandard_characteristics,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/usps_api/models/labels_package_description1.rb', line 80

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['weight_uom'] = 'weightUOM'
  @_hash['weight'] = 'weight'
  @_hash['dimensions_uom'] = 'dimensionsUOM'
  @_hash['length'] = 'length'
  @_hash['height'] = 'height'
  @_hash['width'] = 'width'
  @_hash['girth'] = 'girth'
  @_hash['has_nonstandard_characteristics'] =
    'hasNonstandardCharacteristics'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
# File 'lib/usps_api/models/labels_package_description1.rb', line 109

def self.nullables
  []
end

.optionalsObject

An array for optional fields



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/usps_api/models/labels_package_description1.rb', line 95

def self.optionals
  %w[
    weight_uom
    weight
    dimensions_uom
    length
    height
    width
    girth
    has_nonstandard_characteristics
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



179
180
181
182
183
184
185
186
# File 'lib/usps_api/models/labels_package_description1.rb', line 179

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} weight_uom: #{@weight_uom.inspect}, weight: #{@weight.inspect},"\
  " dimensions_uom: #{@dimensions_uom.inspect}, length: #{@length.inspect}, height:"\
  " #{@height.inspect}, width: #{@width.inspect}, girth: #{@girth.inspect},"\
  " has_nonstandard_characteristics: #{@has_nonstandard_characteristics.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



170
171
172
173
174
175
176
# File 'lib/usps_api/models/labels_package_description1.rb', line 170

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} weight_uom: #{@weight_uom}, weight: #{@weight}, dimensions_uom:"\
  " #{@dimensions_uom}, length: #{@length}, height: #{@height}, width: #{@width}, girth:"\
  " #{@girth}, has_nonstandard_characteristics: #{@has_nonstandard_characteristics},"\
  " additional_properties: #{@additional_properties}>"
end