Class: WalmartApIs::Shipment

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

Overview

Contains information pertaining to a shipment in an 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(destination:, placement_option_id:, shipment_id:, source:, contact_information: SKIP, dates: SKIP, freight_information: SKIP, name: SKIP, selected_delivery_window: SKIP, selected_transportation_option_id: SKIP, self_ship_appointment_details: SKIP, shipment_confirmation_id: SKIP, status: SKIP, tracking_details: SKIP, additional_properties: nil) ⇒ Shipment

Returns a new instance of Shipment.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/walmart_ap_is/models/shipment.rb', line 112

def initialize(destination:, placement_option_id:, shipment_id:, source:,
               contact_information: SKIP, dates: SKIP,
               freight_information: SKIP, name: SKIP,
               selected_delivery_window: SKIP,
               selected_transportation_option_id: SKIP,
               self_ship_appointment_details: SKIP,
               shipment_confirmation_id: SKIP, status: SKIP,
               tracking_details: 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
  @dates = dates unless dates == SKIP
  @destination = destination
  @freight_information = freight_information unless freight_information == SKIP
  @name = name unless name == SKIP
  @placement_option_id = placement_option_id
  @selected_delivery_window = selected_delivery_window unless selected_delivery_window == SKIP
  unless selected_transportation_option_id == SKIP
    @selected_transportation_option_id =
      selected_transportation_option_id
  end
  unless self_ship_appointment_details == SKIP
    @self_ship_appointment_details =
      self_ship_appointment_details
  end
  @shipment_confirmation_id = shipment_confirmation_id unless shipment_confirmation_id == SKIP
  @shipment_id = shipment_id
  @source = source
  @status = status unless status == SKIP
  @tracking_details = tracking_details unless tracking_details == SKIP
  @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.rb', line 14

def contact_information
  @contact_information
end

#datesDates

Specifies the date that the seller expects their shipment will be shipped.

Returns:



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

def dates
  @dates
end

#destinationShipmentDestination

The Walmart Ship Node address and warehouse ID.

Returns:



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

def destination
  @destination
end

#freight_informationFreightInformation

Freight information describes the SKUs that are in transit.

Returns:



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

def freight_information
  @freight_information
end

#nameString

The name of the shipment.

Returns:

  • (String)


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

def name
  @name
end

#placement_option_idString

The identifier of a placement option.

Returns:

  • (String)


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

def placement_option_id
  @placement_option_id
end

#selected_delivery_windowSelectedDeliveryWindow

Selected delivery window attributes.



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

def selected_delivery_window
  @selected_delivery_window
end

#selected_transportation_option_idString

Identifier of a transportation option.

Returns:

  • (String)


42
43
44
# File 'lib/walmart_ap_is/models/shipment.rb', line 42

def selected_transportation_option_id
  @selected_transportation_option_id
end

#self_ship_appointment_detailsArray[SelfShipAppointmentDetails]

List of self ship appointment details.

Returns:



46
47
48
# File 'lib/walmart_ap_is/models/shipment.rb', line 46

def self_ship_appointment_details
  @self_ship_appointment_details
end

#shipment_confirmation_idString

The confirmed shipment ID which shows up on labels.

Returns:

  • (String)


50
51
52
# File 'lib/walmart_ap_is/models/shipment.rb', line 50

def shipment_confirmation_id
  @shipment_confirmation_id
end

#shipment_idString

Identifier of a shipment.

Returns:

  • (String)


54
55
56
# File 'lib/walmart_ap_is/models/shipment.rb', line 54

def shipment_id
  @shipment_id
end

#sourceShipmentSource

Specifies the 'ship from' address for the shipment.

Returns:



58
59
60
# File 'lib/walmart_ap_is/models/shipment.rb', line 58

def source
  @source
end

#statusString

The status of a shipment. Possible values: ABANDONED, CANCELLED, CHECKED_IN, CLOSED, DELETED, DELIVERED, IN_TRANSIT, MIXED, READY_TO_SHIP, RECEIVING, SHIPPED, UNCONFIRMED, WORKING.

Returns:

  • (String)


64
65
66
# File 'lib/walmart_ap_is/models/shipment.rb', line 64

def status
  @status
end

#tracking_detailsTrackingDetails

Tracking information for LTL and SPD shipments.

Returns:



68
69
70
# File 'lib/walmart_ap_is/models/shipment.rb', line 68

def tracking_details
  @tracking_details
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/walmart_ap_is/models/shipment.rb', line 147

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  destination = ShipmentDestination.from_hash(hash['destination']) if hash['destination']
  placement_option_id =
    hash.key?('placementOptionId') ? hash['placementOptionId'] : nil
  shipment_id = hash.key?('shipmentId') ? hash['shipmentId'] : nil
  source = ShipmentSource.from_hash(hash['source']) if hash['source']
  contact_information = ContactInformation.from_hash(hash['contactInformation']) if
    hash['contactInformation']
  dates = Dates.from_hash(hash['dates']) if hash['dates']
  freight_information = FreightInformation.from_hash(hash['freightInformation']) if
    hash['freightInformation']
  name = hash.key?('name') ? hash['name'] : SKIP
  selected_delivery_window = SelectedDeliveryWindow.from_hash(hash['selectedDeliveryWindow']) if
    hash['selectedDeliveryWindow']
  selected_transportation_option_id =
    hash.key?('selectedTransportationOptionId') ? hash['selectedTransportationOptionId'] : SKIP
  # Parameter is an array, so we need to iterate through it
  self_ship_appointment_details = nil
  unless hash['selfShipAppointmentDetails'].nil?
    self_ship_appointment_details = []
    hash['selfShipAppointmentDetails'].each do |structure|
      self_ship_appointment_details << (SelfShipAppointmentDetails.from_hash(structure) if structure)
    end
  end

  self_ship_appointment_details = SKIP unless hash.key?('selfShipAppointmentDetails')
  shipment_confirmation_id =
    hash.key?('shipmentConfirmationId') ? hash['shipmentConfirmationId'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  tracking_details = TrackingDetails.from_hash(hash['trackingDetails']) if
    hash['trackingDetails']

  # 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.
  Shipment.new(destination: destination,
               placement_option_id: placement_option_id,
               shipment_id: shipment_id,
               source: source,
               contact_information: contact_information,
               dates: dates,
               freight_information: freight_information,
               name: name,
               selected_delivery_window: selected_delivery_window,
               selected_transportation_option_id: selected_transportation_option_id,
               self_ship_appointment_details: self_ship_appointment_details,
               shipment_confirmation_id: shipment_confirmation_id,
               status: status,
               tracking_details: tracking_details,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/walmart_ap_is/models/shipment.rb', line 71

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['contact_information'] = 'contactInformation'
  @_hash['dates'] = 'dates'
  @_hash['destination'] = 'destination'
  @_hash['freight_information'] = 'freightInformation'
  @_hash['name'] = 'name'
  @_hash['placement_option_id'] = 'placementOptionId'
  @_hash['selected_delivery_window'] = 'selectedDeliveryWindow'
  @_hash['selected_transportation_option_id'] =
    'selectedTransportationOptionId'
  @_hash['self_ship_appointment_details'] = 'selfShipAppointmentDetails'
  @_hash['shipment_confirmation_id'] = 'shipmentConfirmationId'
  @_hash['shipment_id'] = 'shipmentId'
  @_hash['source'] = 'source'
  @_hash['status'] = 'status'
  @_hash['tracking_details'] = 'trackingDetails'
  @_hash
end

.nullablesObject

An array for nullable fields



108
109
110
# File 'lib/walmart_ap_is/models/shipment.rb', line 108

def self.nullables
  []
end

.optionalsObject

An array for optional fields



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/walmart_ap_is/models/shipment.rb', line 92

def self.optionals
  %w[
    contact_information
    dates
    freight_information
    name
    selected_delivery_window
    selected_transportation_option_id
    self_ship_appointment_details
    shipment_confirmation_id
    status
    tracking_details
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/walmart_ap_is/models/shipment.rb', line 221

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} contact_information: #{@contact_information.inspect}, dates:"\
  " #{@dates.inspect}, destination: #{@destination.inspect}, freight_information:"\
  " #{@freight_information.inspect}, name: #{@name.inspect}, placement_option_id:"\
  " #{@placement_option_id.inspect}, selected_delivery_window:"\
  " #{@selected_delivery_window.inspect}, selected_transportation_option_id:"\
  " #{@selected_transportation_option_id.inspect}, self_ship_appointment_details:"\
  " #{@self_ship_appointment_details.inspect}, shipment_confirmation_id:"\
  " #{@shipment_confirmation_id.inspect}, shipment_id: #{@shipment_id.inspect}, source:"\
  " #{@source.inspect}, status: #{@status.inspect}, tracking_details:"\
  " #{@tracking_details.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



208
209
210
211
212
213
214
215
216
217
218
# File 'lib/walmart_ap_is/models/shipment.rb', line 208

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} contact_information: #{@contact_information}, dates: #{@dates},"\
  " destination: #{@destination}, freight_information: #{@freight_information}, name:"\
  " #{@name}, placement_option_id: #{@placement_option_id}, selected_delivery_window:"\
  " #{@selected_delivery_window}, selected_transportation_option_id:"\
  " #{@selected_transportation_option_id}, self_ship_appointment_details:"\
  " #{@self_ship_appointment_details}, shipment_confirmation_id: #{@shipment_confirmation_id},"\
  " shipment_id: #{@shipment_id}, source: #{@source}, status: #{@status}, tracking_details:"\
  " #{@tracking_details}, additional_properties: #{@additional_properties}>"
end