Class: WalmartApIs::ShipmentDestination

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

Overview

The Walmart Ship Node address and warehouse ID.

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_type:, address: SKIP, warehouse_id: SKIP, additional_properties: nil) ⇒ ShipmentDestination

Returns a new instance of ShipmentDestination.



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

def initialize(destination_type:, address: SKIP, warehouse_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @address = address unless address == SKIP
  @destination_type = destination_type
  @warehouse_id = warehouse_id unless warehouse_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressAddress

Specific details to identify a place.

Returns:



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

def address
  @address
end

#destination_typeString

The type of destination for this shipment. Possible values: WALMART_OPTIMIZED, WALMART_SHIP_NODE.

Returns:

  • (String)


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

def destination_type
  @destination_type
end

#warehouse_idString

The Ship Node that the shipment should be sent to. This can be empty if the destination type is WALMART_OPTIMIZED.

Returns:

  • (String)


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

def warehouse_id
  @warehouse_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
# File 'lib/walmart_ap_is/models/shipment_destination.rb', line 60

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  destination_type =
    hash.key?('destinationType') ? hash['destinationType'] : nil
  address = Address.from_hash(hash['address']) if hash['address']
  warehouse_id = hash.key?('warehouseId') ? hash['warehouseId'] : 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.
  ShipmentDestination.new(destination_type: destination_type,
                          address: address,
                          warehouse_id: warehouse_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/shipment_destination.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address'] = 'address'
  @_hash['destination_type'] = 'destinationType'
  @_hash['warehouse_id'] = 'warehouseId'
  @_hash
end

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/walmart_ap_is/models/shipment_destination.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/shipment_destination.rb', line 36

def self.optionals
  %w[
    address
    warehouse_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



91
92
93
94
95
96
# File 'lib/walmart_ap_is/models/shipment_destination.rb', line 91

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

#to_sObject

Provides a human-readable string representation of the object.



84
85
86
87
88
# File 'lib/walmart_ap_is/models/shipment_destination.rb', line 84

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