Class: WalmartApIs::BoxUpdateInput

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

Overview

Input information for updating a box.

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(content_information_source:, dimensions:, quantity:, weight:, items: SKIP, package_id: SKIP, additional_properties: nil) ⇒ BoxUpdateInput

Returns a new instance of BoxUpdateInput.



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 65

def initialize(content_information_source:, dimensions:, quantity:, weight:,
               items: SKIP, package_id: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @content_information_source = 
  @dimensions = dimensions
  @items = items unless items == SKIP
  @package_id = package_id unless package_id == SKIP
  @quantity = quantity
  @weight = weight
  @additional_properties = additional_properties
end

Instance Attribute Details

#content_information_sourceBoxContentInformationSource

Indication of how box content is meant to be provided.



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

def 
  @content_information_source
end

#dimensionsDimensions

Measurement of a package's dimensions.

Returns:



18
19
20
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 18

def dimensions
  @dimensions
end

#itemsArray[ItemInput]

The items and their quantity in the box. This must be empty if the box contentInformationSource is BARCODE_2D or MANUAL_PROCESS.

Returns:



23
24
25
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 23

def items
  @items
end

#package_idString

Primary key to uniquely identify a Box Package. Provide to update an existing box; omit to add a new box. Any existing packageIds not provided will be treated as to-be-removed.

Returns:

  • (String)


29
30
31
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 29

def package_id
  @package_id
end

#quantityInteger

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

Returns:

  • (Integer)


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

def quantity
  @quantity
end

#weightWeight

The weight of a package.

Returns:



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

def weight
  @weight
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
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
110
111
112
113
114
115
116
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   =
    hash.key?('contentInformationSource') ? hash['contentInformationSource'] : nil
  dimensions = Dimensions.from_hash(hash['dimensions']) if hash['dimensions']
  quantity = hash.key?('quantity') ? hash['quantity'] : nil
  weight = Weight.from_hash(hash['weight']) if hash['weight']
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (ItemInput.from_hash(structure) if structure)
    end
  end

  items = SKIP unless hash.key?('items')
  package_id = hash.key?('packageId') ? hash['packageId'] : SKIP

  # 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.
  BoxUpdateInput.new(content_information_source: ,
                     dimensions: dimensions,
                     quantity: quantity,
                     weight: weight,
                     items: items,
                     package_id: package_id,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['content_information_source'] = 'contentInformationSource'
  @_hash['dimensions'] = 'dimensions'
  @_hash['items'] = 'items'
  @_hash['package_id'] = 'packageId'
  @_hash['quantity'] = 'quantity'
  @_hash['weight'] = 'weight'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



53
54
55
56
57
58
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 53

def self.optionals
  %w[
    items
    package_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



127
128
129
130
131
132
133
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 127

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} content_information_source: #{@content_information_source.inspect},"\
  " dimensions: #{@dimensions.inspect}, items: #{@items.inspect}, package_id:"\
  " #{@package_id.inspect}, quantity: #{@quantity.inspect}, weight: #{@weight.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



119
120
121
122
123
124
# File 'lib/walmart_ap_is/models/box_update_input.rb', line 119

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} content_information_source: #{@content_information_source}, dimensions:"\
  " #{@dimensions}, items: #{@items}, package_id: #{@package_id}, quantity: #{@quantity},"\
  " weight: #{@weight}, additional_properties: #{@additional_properties}>"
end