Class: WalmartApIs::BoxInput

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

Overview

Input information for a given 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, additional_properties: nil) ⇒ BoxInput

Returns a new instance of BoxInput.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/walmart_ap_is/models/box_input.rb', line 57

def initialize(content_information_source:, dimensions:, quantity:, weight:,
               items: 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
  @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_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_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_input.rb', line 23

def items
  @items
end

#quantityInteger

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

Returns:

  • (Integer)


28
29
30
# File 'lib/walmart_ap_is/models/box_input.rb', line 28

def quantity
  @quantity
end

#weightWeight

The weight of a package.

Returns:



32
33
34
# File 'lib/walmart_ap_is/models/box_input.rb', line 32

def weight
  @weight
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



71
72
73
74
75
76
77
78
79
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
# File 'lib/walmart_ap_is/models/box_input.rb', line 71

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')

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

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
43
# File 'lib/walmart_ap_is/models/box_input.rb', line 35

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

.nullablesObject

An array for nullable fields



53
54
55
# File 'lib/walmart_ap_is/models/box_input.rb', line 53

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
# File 'lib/walmart_ap_is/models/box_input.rb', line 46

def self.optionals
  %w[
    items
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



116
117
118
119
120
121
122
# File 'lib/walmart_ap_is/models/box_input.rb', line 116

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

#to_sObject

Provides a human-readable string representation of the object.



108
109
110
111
112
113
# File 'lib/walmart_ap_is/models/box_input.rb', line 108

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