Class: WalmartApIs::BoxInput
- Defined in:
- lib/walmart_ap_is/models/box_input.rb
Overview
Input information for a given box.
Instance Attribute Summary collapse
-
#content_information_source ⇒ BoxContentInformationSource
Indication of how box content is meant to be provided.
-
#dimensions ⇒ Dimensions
Measurement of a package's dimensions.
-
#items ⇒ Array[ItemInput]
The items and their quantity in the box.
-
#quantity ⇒ Integer
The number of containers where all other properties like weight or dimensions are identical.
-
#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(content_information_source:, dimensions:, quantity:, weight:, items: SKIP, additional_properties: nil) ⇒ BoxInput
constructor
A new instance of BoxInput.
-
#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(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 = content_information_source @dimensions = dimensions @items = items unless items == SKIP @quantity = quantity @weight = weight @additional_properties = additional_properties end |
Instance Attribute Details
#content_information_source ⇒ BoxContentInformationSource
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 @content_information_source end |
#dimensions ⇒ Dimensions
Measurement of a package's dimensions.
18 19 20 |
# File 'lib/walmart_ap_is/models/box_input.rb', line 18 def dimensions @dimensions end |
#items ⇒ Array[ItemInput]
The items and their quantity in the box. This must be empty if the box
contentInformationSource is BARCODE_2D or MANUAL_PROCESS.
23 24 25 |
# File 'lib/walmart_ap_is/models/box_input.rb', line 23 def items @items end |
#quantity ⇒ Integer
The number of containers where all other properties like weight or dimensions are identical.
28 29 30 |
# File 'lib/walmart_ap_is/models/box_input.rb', line 28 def quantity @quantity end |
#weight ⇒ Weight
The weight of a package.
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. content_information_source = 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: content_information_source, dimensions: dimensions, quantity: quantity, weight: weight, items: items, additional_properties: additional_properties) end |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
53 54 55 |
# File 'lib/walmart_ap_is/models/box_input.rb', line 53 def self.nullables [] end |
.optionals ⇒ Object
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
#inspect ⇒ Object
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_s ⇒ Object
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 |