Class: WalmartApIs::Box

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/box.rb

Overview

Contains information about a box used in the inbound plan.

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(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  == SKIP
    @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_idString

The ID provided by Walmart that identifies a given box.

Returns:

  • (String)


14
15
16
# File 'lib/walmart_ap_is/models/box.rb', line 14

def box_id
  @box_id
end

#content_information_sourceBoxContentInformationSource

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
end

#destination_regionRegion

Representation of a location used within the inbounding experience.

Returns:



22
23
24
# File 'lib/walmart_ap_is/models/box.rb', line 22

def destination_region
  @destination_region
end

#dimensionsDimensions

Measurement of a package's dimensions.

Returns:



26
27
28
# File 'lib/walmart_ap_is/models/box.rb', line 26

def dimensions
  @dimensions
end

#external_container_identifierString

The external identifier for this container / box.

Returns:

  • (String)


30
31
32
# File 'lib/walmart_ap_is/models/box.rb', line 30

def external_container_identifier
  @external_container_identifier
end

#external_container_identifier_typeString

Type of the external identifier used. Can be: WALMART, SSCC.

Returns:

  • (String)


34
35
36
# File 'lib/walmart_ap_is/models/box.rb', line 34

def external_container_identifier_type
  @external_container_identifier_type
end

#itemsArray[Item1]

Items contained within the box.

Returns:



38
39
40
# File 'lib/walmart_ap_is/models/box.rb', line 38

def items
  @items
end

#package_idString

Primary key to uniquely identify a Package (Box or Pallet).

Returns:

  • (String)


42
43
44
# File 'lib/walmart_ap_is/models/box.rb', line 42

def package_id
  @package_id
end

#quantityInteger

The number of containers where all other properties like weight or dimensions are identical.

Returns:

  • (Integer)


47
48
49
# File 'lib/walmart_ap_is/models/box.rb', line 47

def quantity
  @quantity
end

#template_nameString

Template name of the box.

Returns:

  • (String)


51
52
53
# File 'lib/walmart_ap_is/models/box.rb', line 51

def template_name
  @template_name
end

#weightWeight

The weight of a package.

Returns:



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
   =
    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: ,
          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

.namesObject

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

.nullablesObject

An array for nullable fields



92
93
94
# File 'lib/walmart_ap_is/models/box.rb', line 92

def self.nullables
  []
end

.optionalsObject

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

#inspectObject

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_sObject

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