Class: WalmartApIs::PackageGroupingInput

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

Overview

Packing information for 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(boxes:, packing_group_id: SKIP, shipment_id: SKIP, additional_properties: nil) ⇒ PackageGroupingInput

Returns a new instance of PackageGroupingInput.



48
49
50
51
52
53
54
55
56
57
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 48

def initialize(boxes:, packing_group_id: SKIP, shipment_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @boxes = boxes
  @packing_group_id = packing_group_id unless packing_group_id == SKIP
  @shipment_id = shipment_id unless shipment_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#boxesArray[BoxInput]

Box level information being provided.

Returns:



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

def boxes
  @boxes
end

#packing_group_idString

The ID of the packingGroup that packages are grouped according to. Provide before placement confirmation.

Returns:

  • (String)


19
20
21
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 19

def packing_group_id
  @packing_group_id
end

#shipment_idString

The ID of the shipment that packages are grouped according to. Provide after placement confirmation.

Returns:

  • (String)


24
25
26
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 24

def shipment_id
  @shipment_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 60

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  boxes = nil
  unless hash['boxes'].nil?
    boxes = []
    hash['boxes'].each do |structure|
      boxes << (BoxInput.from_hash(structure) if structure)
    end
  end

  boxes = nil unless hash.key?('boxes')
  packing_group_id =
    hash.key?('packingGroupId') ? hash['packingGroupId'] : SKIP
  shipment_id = hash.key?('shipmentId') ? hash['shipmentId'] : 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.
  PackageGroupingInput.new(boxes: boxes,
                           packing_group_id: packing_group_id,
                           shipment_id: shipment_id,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['boxes'] = 'boxes'
  @_hash['packing_group_id'] = 'packingGroupId'
  @_hash['shipment_id'] = 'shipmentId'
  @_hash
end

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 36

def self.optionals
  %w[
    packing_group_id
    shipment_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



100
101
102
103
104
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 100

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} boxes: #{@boxes.inspect}, packing_group_id: #{@packing_group_id.inspect},"\
  " shipment_id: #{@shipment_id.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



93
94
95
96
97
# File 'lib/walmart_ap_is/models/package_grouping_input.rb', line 93

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} boxes: #{@boxes}, packing_group_id: #{@packing_group_id}, shipment_id:"\
  " #{@shipment_id}, additional_properties: #{@additional_properties}>"
end