Class: WalmartApIs::Box
- Defined in:
- lib/walmart_ap_is/models/box.rb
Overview
Contains information about a box used in the inbound plan.
Instance Attribute Summary collapse
-
#box_id ⇒ String
The ID provided by Walmart that identifies a given box.
-
#content_information_source ⇒ BoxContentInformationSource
Indication of how box content is meant to be provided.
-
#destination_region ⇒ Region
Representation of a location used within the inbounding experience.
-
#dimensions ⇒ Dimensions
Measurement of a package's dimensions.
-
#external_container_identifier ⇒ String
The external identifier for this container / box.
-
#external_container_identifier_type ⇒ String
Type of the external identifier used.
-
#items ⇒ Array[Item1]
Items contained within the box.
-
#package_id ⇒ String
Primary key to uniquely identify a Package (Box or Pallet).
-
#quantity ⇒ Integer
The number of containers where all other properties like weight or dimensions are identical.
-
#template_name ⇒ String
Template name of the box.
-
#weight ⇒ Weight
The weight of a package.
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(package_id:, box_id: SKIP, content_information_source: SKIP, destination_region: SKIP, dimensions: SKIP, external_container_identifier: SKIP, external_container_identifier_type: SKIP, items: SKIP, quantity: SKIP, template_name: SKIP, weight: SKIP, additional_properties: nil) ⇒ Box
constructor
A new instance of Box.
-
#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(package_id:, box_id: SKIP, content_information_source: SKIP, destination_region: SKIP, dimensions: SKIP, external_container_identifier: SKIP, external_container_identifier_type: SKIP, items: SKIP, quantity: SKIP, template_name: SKIP, weight: SKIP, additional_properties: nil) ⇒ Box
Returns a new instance of Box.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/walmart_ap_is/models/box.rb', line 96 def initialize(package_id:, box_id: SKIP, content_information_source: SKIP, destination_region: SKIP, dimensions: SKIP, external_container_identifier: SKIP, external_container_identifier_type: SKIP, items: SKIP, quantity: SKIP, template_name: SKIP, weight: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @box_id = box_id unless box_id == SKIP unless content_information_source == SKIP @content_information_source = content_information_source end @destination_region = destination_region unless destination_region == SKIP @dimensions = dimensions unless dimensions == SKIP unless external_container_identifier == SKIP @external_container_identifier = external_container_identifier end unless external_container_identifier_type == SKIP @external_container_identifier_type = external_container_identifier_type end @items = items unless items == SKIP @package_id = package_id @quantity = quantity unless quantity == SKIP @template_name = template_name unless template_name == SKIP @weight = weight unless weight == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#box_id ⇒ String
The ID provided by Walmart that identifies a given box.
14 15 16 |
# File 'lib/walmart_ap_is/models/box.rb', line 14 def box_id @box_id end |
#content_information_source ⇒ BoxContentInformationSource
Indication of how box content is meant to be provided.
18 19 20 |
# File 'lib/walmart_ap_is/models/box.rb', line 18 def content_information_source @content_information_source end |
#destination_region ⇒ Region
Representation of a location used within the inbounding experience.
22 23 24 |
# File 'lib/walmart_ap_is/models/box.rb', line 22 def destination_region @destination_region end |
#dimensions ⇒ Dimensions
Measurement of a package's dimensions.
26 27 28 |
# File 'lib/walmart_ap_is/models/box.rb', line 26 def dimensions @dimensions end |
#external_container_identifier ⇒ String
The external identifier for this container / box.
30 31 32 |
# File 'lib/walmart_ap_is/models/box.rb', line 30 def external_container_identifier @external_container_identifier end |
#external_container_identifier_type ⇒ String
Type of the external identifier used. Can be: WALMART, SSCC.
34 35 36 |
# File 'lib/walmart_ap_is/models/box.rb', line 34 def external_container_identifier_type @external_container_identifier_type end |
#items ⇒ Array[Item1]
Items contained within the box.
38 39 40 |
# File 'lib/walmart_ap_is/models/box.rb', line 38 def items @items end |
#package_id ⇒ String
Primary key to uniquely identify a Package (Box or Pallet).
42 43 44 |
# File 'lib/walmart_ap_is/models/box.rb', line 42 def package_id @package_id end |
#quantity ⇒ Integer
The number of containers where all other properties like weight or dimensions are identical.
47 48 49 |
# File 'lib/walmart_ap_is/models/box.rb', line 47 def quantity @quantity end |
#template_name ⇒ String
Template name of the box.
51 52 53 |
# File 'lib/walmart_ap_is/models/box.rb', line 51 def template_name @template_name end |
#weight ⇒ Weight
The weight of a package.
55 56 57 |
# File 'lib/walmart_ap_is/models/box.rb', line 55 def weight @weight end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
129 130 131 132 133 134 135 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 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/walmart_ap_is/models/box.rb', line 129 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. package_id = hash.key?('packageId') ? hash['packageId'] : nil box_id = hash.key?('boxId') ? hash['boxId'] : SKIP content_information_source = hash.key?('contentInformationSource') ? hash['contentInformationSource'] : SKIP destination_region = Region.from_hash(hash['destinationRegion']) if hash['destinationRegion'] dimensions = Dimensions.from_hash(hash['dimensions']) if hash['dimensions'] external_container_identifier = hash.key?('externalContainerIdentifier') ? hash['externalContainerIdentifier'] : SKIP external_container_identifier_type = hash.key?('externalContainerIdentifierType') ? hash['externalContainerIdentifierType'] : SKIP # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (Item1.from_hash(structure) if structure) end end items = SKIP unless hash.key?('items') quantity = hash.key?('quantity') ? hash['quantity'] : SKIP template_name = hash.key?('templateName') ? hash['templateName'] : SKIP weight = Weight.from_hash(hash['weight']) if hash['weight'] # 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. Box.new(package_id: package_id, box_id: box_id, content_information_source: content_information_source, destination_region: destination_region, dimensions: dimensions, external_container_identifier: external_container_identifier, external_container_identifier_type: external_container_identifier_type, items: items, quantity: quantity, template_name: template_name, weight: weight, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/walmart_ap_is/models/box.rb', line 58 def self.names @_hash = {} if @_hash.nil? @_hash['box_id'] = 'boxId' @_hash['content_information_source'] = 'contentInformationSource' @_hash['destination_region'] = 'destinationRegion' @_hash['dimensions'] = 'dimensions' @_hash['external_container_identifier'] = 'externalContainerIdentifier' @_hash['external_container_identifier_type'] = 'externalContainerIdentifierType' @_hash['items'] = 'items' @_hash['package_id'] = 'packageId' @_hash['quantity'] = 'quantity' @_hash['template_name'] = 'templateName' @_hash['weight'] = 'weight' @_hash end |
.nullables ⇒ Object
An array for nullable fields
92 93 94 |
# File 'lib/walmart_ap_is/models/box.rb', line 92 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/walmart_ap_is/models/box.rb', line 76 def self.optionals %w[ box_id content_information_source destination_region dimensions external_container_identifier external_container_identifier_type items quantity template_name weight ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/walmart_ap_is/models/box.rb', line 192 def inspect class_name = self.class.name.split('::').last "<#{class_name} box_id: #{@box_id.inspect}, content_information_source:"\ " #{@content_information_source.inspect}, destination_region:"\ " #{@destination_region.inspect}, dimensions: #{@dimensions.inspect},"\ " external_container_identifier: #{@external_container_identifier.inspect},"\ " external_container_identifier_type: #{@external_container_identifier_type.inspect}, items:"\ " #{@items.inspect}, package_id: #{@package_id.inspect}, quantity: #{@quantity.inspect},"\ " template_name: #{@template_name.inspect}, weight: #{@weight.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
181 182 183 184 185 186 187 188 189 |
# File 'lib/walmart_ap_is/models/box.rb', line 181 def to_s class_name = self.class.name.split('::').last "<#{class_name} box_id: #{@box_id}, content_information_source:"\ " #{@content_information_source}, destination_region: #{@destination_region}, dimensions:"\ " #{@dimensions}, external_container_identifier: #{@external_container_identifier},"\ " external_container_identifier_type: #{@external_container_identifier_type}, items:"\ " #{@items}, package_id: #{@package_id}, quantity: #{@quantity}, template_name:"\ " #{@template_name}, weight: #{@weight}, additional_properties: #{@additional_properties}>" end |