Class: WalmartApIs::ShipmentTransportationConfiguration

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

Overview

Details needed to generate the transportation options.

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(ready_to_ship_window:, shipment_id:, contact_information: SKIP, freight_information: SKIP, pallets: SKIP, additional_properties: nil) ⇒ ShipmentTransportationConfiguration

Returns a new instance of ShipmentTransportationConfiguration.



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

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

  @contact_information = contact_information unless contact_information == SKIP
  @freight_information = freight_information unless freight_information == SKIP
  @pallets = pallets unless pallets == SKIP
  @ready_to_ship_window = ready_to_ship_window
  @shipment_id = shipment_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#contact_informationContactInformation

The seller's contact information.

Returns:



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

def contact_information
  @contact_information
end

#freight_informationFreightInformation

Freight information describes the SKUs that are in transit.

Returns:



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

def freight_information
  @freight_information
end

#palletsArray[PalletInput]

List of pallet configuration inputs.

Returns:



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

def pallets
  @pallets
end

#ready_to_ship_windowWindowInput

Contains only a starting DateTime.

Returns:



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

def ready_to_ship_window
  @ready_to_ship_window
end

#shipment_idString

Identifier of a shipment.

Returns:

  • (String)


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

def shipment_id
  @shipment_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
106
107
108
# File 'lib/walmart_ap_is/models/shipment_transportation_configuration.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  ready_to_ship_window = WindowInput.from_hash(hash['readyToShipWindow']) if
    hash['readyToShipWindow']
  shipment_id = hash.key?('shipmentId') ? hash['shipmentId'] : nil
  contact_information = ContactInformation.from_hash(hash['contactInformation']) if
    hash['contactInformation']
  freight_information = FreightInformation.from_hash(hash['freightInformation']) if
    hash['freightInformation']
  # Parameter is an array, so we need to iterate through it
  pallets = nil
  unless hash['pallets'].nil?
    pallets = []
    hash['pallets'].each do |structure|
      pallets << (PalletInput.from_hash(structure) if structure)
    end
  end

  pallets = SKIP unless hash.key?('pallets')

  # 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.
  ShipmentTransportationConfiguration.new(ready_to_ship_window: ready_to_ship_window,
                                          shipment_id: shipment_id,
                                          contact_information: contact_information,
                                          freight_information: freight_information,
                                          pallets: pallets,
                                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/walmart_ap_is/models/shipment_transportation_configuration.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['contact_information'] = 'contactInformation'
  @_hash['freight_information'] = 'freightInformation'
  @_hash['pallets'] = 'pallets'
  @_hash['ready_to_ship_window'] = 'readyToShipWindow'
  @_hash['shipment_id'] = 'shipmentId'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    contact_information
    freight_information
    pallets
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



120
121
122
123
124
125
126
# File 'lib/walmart_ap_is/models/shipment_transportation_configuration.rb', line 120

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

#to_sObject

Provides a human-readable string representation of the object.



111
112
113
114
115
116
117
# File 'lib/walmart_ap_is/models/shipment_transportation_configuration.rb', line 111

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