Class: WalmartApIs::ShipmentRequestDetails

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

Overview

ShipmentRequestDetails Model.

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(purchase_order_id:, ship_from_address:, ship_to_address:, package_dimensions:, weight:, ship_date:, shipping_service_options:, seller_order_id: SKIP, item_list: SKIP, additional_properties: nil) ⇒ ShipmentRequestDetails

Returns a new instance of ShipmentRequestDetails.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 77

def initialize(purchase_order_id:, ship_from_address:, ship_to_address:,
               package_dimensions:, weight:, ship_date:,
               shipping_service_options:, seller_order_id: SKIP,
               item_list: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @purchase_order_id = purchase_order_id
  @seller_order_id = seller_order_id unless seller_order_id == SKIP
  @item_list = item_list unless item_list == SKIP
  @ship_from_address = ship_from_address
  @ship_to_address = ship_to_address
  @package_dimensions = package_dimensions
  @weight = weight
  @ship_date = ship_date
  @shipping_service_options = shipping_service_options
  @additional_properties = additional_properties
end

Instance Attribute Details

#item_listArray[Item2]

Walmart Purchase Order ID

Returns:



23
24
25
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 23

def item_list
  @item_list
end

#package_dimensionsPackageDimensions

Walmart Purchase Order ID

Returns:



35
36
37
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 35

def package_dimensions
  @package_dimensions
end

#purchase_order_idString

Walmart Purchase Order ID

Returns:

  • (String)


15
16
17
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 15

def purchase_order_id
  @purchase_order_id
end

#seller_order_idString

Walmart Purchase Order ID

Returns:

  • (String)


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

def seller_order_id
  @seller_order_id
end

#ship_dateDateTime

Walmart Purchase Order ID

Returns:

  • (DateTime)


43
44
45
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 43

def ship_date
  @ship_date
end

#ship_from_addressAddress1

Walmart Purchase Order ID

Returns:



27
28
29
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 27

def ship_from_address
  @ship_from_address
end

#ship_to_addressAddress1

Walmart Purchase Order ID

Returns:



31
32
33
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 31

def ship_to_address
  @ship_to_address
end

#shipping_service_optionsShippingServiceOptions

Walmart Purchase Order ID



47
48
49
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 47

def shipping_service_options
  @shipping_service_options
end

#weightWeight

Walmart Purchase Order ID

Returns:



39
40
41
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 39

def weight
  @weight
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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_request_details.rb', line 97

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  purchase_order_id =
    hash.key?('purchaseOrderId') ? hash['purchaseOrderId'] : nil
  ship_from_address = Address1.from_hash(hash['shipFromAddress']) if hash['shipFromAddress']
  ship_to_address = Address1.from_hash(hash['shipToAddress']) if hash['shipToAddress']
  package_dimensions = PackageDimensions.from_hash(hash['packageDimensions']) if
    hash['packageDimensions']
  weight = Weight.from_hash(hash['weight']) if hash['weight']
  ship_date = if hash.key?('shipDate')
                (DateTimeHelper.from_rfc3339(hash['shipDate']) if hash['shipDate'])
              end
  shipping_service_options = ShippingServiceOptions.from_hash(hash['shippingServiceOptions']) if
    hash['shippingServiceOptions']
  seller_order_id =
    hash.key?('sellerOrderId') ? hash['sellerOrderId'] : SKIP
  # Parameter is an array, so we need to iterate through it
  item_list = nil
  unless hash['itemList'].nil?
    item_list = []
    hash['itemList'].each do |structure|
      item_list << (Item2.from_hash(structure) if structure)
    end
  end

  item_list = SKIP unless hash.key?('itemList')

  # 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.
  ShipmentRequestDetails.new(purchase_order_id: purchase_order_id,
                             ship_from_address: ship_from_address,
                             ship_to_address: ship_to_address,
                             package_dimensions: package_dimensions,
                             weight: weight,
                             ship_date: ship_date,
                             shipping_service_options: shipping_service_options,
                             seller_order_id: seller_order_id,
                             item_list: item_list,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 50

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['purchase_order_id'] = 'purchaseOrderId'
  @_hash['seller_order_id'] = 'sellerOrderId'
  @_hash['item_list'] = 'itemList'
  @_hash['ship_from_address'] = 'shipFromAddress'
  @_hash['ship_to_address'] = 'shipToAddress'
  @_hash['package_dimensions'] = 'packageDimensions'
  @_hash['weight'] = 'weight'
  @_hash['ship_date'] = 'shipDate'
  @_hash['shipping_service_options'] = 'shippingServiceOptions'
  @_hash
end

.nullablesObject

An array for nullable fields



73
74
75
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 73

def self.nullables
  []
end

.optionalsObject

An array for optional fields



65
66
67
68
69
70
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 65

def self.optionals
  %w[
    seller_order_id
    item_list
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



161
162
163
164
165
166
167
168
169
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 161

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} purchase_order_id: #{@purchase_order_id.inspect}, seller_order_id:"\
  " #{@seller_order_id.inspect}, item_list: #{@item_list.inspect}, ship_from_address:"\
  " #{@ship_from_address.inspect}, ship_to_address: #{@ship_to_address.inspect},"\
  " package_dimensions: #{@package_dimensions.inspect}, weight: #{@weight.inspect}, ship_date:"\
  " #{@ship_date.inspect}, shipping_service_options: #{@shipping_service_options.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_ship_dateObject



146
147
148
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 146

def to_custom_ship_date
  DateTimeHelper.to_rfc3339(ship_date)
end

#to_sObject

Provides a human-readable string representation of the object.



151
152
153
154
155
156
157
158
# File 'lib/walmart_ap_is/models/shipment_request_details.rb', line 151

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} purchase_order_id: #{@purchase_order_id}, seller_order_id:"\
  " #{@seller_order_id}, item_list: #{@item_list}, ship_from_address: #{@ship_from_address},"\
  " ship_to_address: #{@ship_to_address}, package_dimensions: #{@package_dimensions}, weight:"\
  " #{@weight}, ship_date: #{@ship_date}, shipping_service_options:"\
  " #{@shipping_service_options}, additional_properties: #{@additional_properties}>"
end