Class: WalmartApIs::InboundPlan

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

Overview

Inbound plan containing details of the WFS inbound workflow.

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(created_at:, inbound_plan_id:, last_updated_at:, marketplace_ids:, name:, source_address:, status:, packing_options: SKIP, placement_options: SKIP, shipments: SKIP, additional_properties: nil) ⇒ InboundPlan

Returns a new instance of InboundPlan.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 89

def initialize(created_at:, inbound_plan_id:, last_updated_at:,
               marketplace_ids:, name:, source_address:, status:,
               packing_options: SKIP, placement_options: SKIP,
               shipments: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @created_at = created_at
  @inbound_plan_id = inbound_plan_id
  @last_updated_at = last_updated_at
  @marketplace_ids = marketplace_ids
  @name = name
  @packing_options = packing_options unless packing_options == SKIP
  @placement_options = placement_options unless placement_options == SKIP
  @shipments = shipments unless shipments == SKIP
  @source_address = source_address
  @status = status
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_atDateTime

The time at which the inbound plan was created. In ISO 8601 datetime format with pattern yyyy-MM-ddTHH:mm:ssZ.

Returns:

  • (DateTime)


16
17
18
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 16

def created_at
  @created_at
end

#inbound_plan_idString

Identifier of an inbound plan.

Returns:

  • (String)


20
21
22
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 20

def inbound_plan_id
  @inbound_plan_id
end

#last_updated_atDateTime

The time at which the inbound plan was last updated. In ISO 8601 datetime format with pattern yyyy-MM-ddTHH:mm:ssZ.

Returns:

  • (DateTime)


25
26
27
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 25

def last_updated_at
  @last_updated_at
end

#marketplace_idsArray[String]

A list of Walmart marketplace IDs.

Returns:

  • (Array[String])


29
30
31
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 29

def marketplace_ids
  @marketplace_ids
end

#nameString

Human-readable name of the inbound plan.

Returns:

  • (String)


33
34
35
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 33

def name
  @name
end

#packing_optionsArray[PackingOptionSummary]

Packing options for the inbound plan. Populated after generation via the corresponding operation.

Returns:



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

def packing_options
  @packing_options
end

#placement_optionsArray[PlacementOptionSummary]

Placement options for the inbound plan. Populated after generation via the corresponding operation.

Returns:



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

def placement_options
  @placement_options
end

#shipmentsArray[ShipmentSummary]

A list of shipment IDs for the inbound plan. Populated after confirmPlacementOptions.

Returns:



48
49
50
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 48

def shipments
  @shipments
end

#source_addressAddress

Specific details to identify a place.

Returns:



52
53
54
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 52

def source_address
  @source_address
end

#statusString

Current status of the inbound plan. Possible values: ACTIVE, VOIDED, SHIPPED, ERRORED.

Returns:

  • (String)


57
58
59
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 57

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
145
146
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
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 110

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  created_at = if hash.key?('createdAt')
                 (DateTimeHelper.from_rfc3339(hash['createdAt']) if hash['createdAt'])
               end
  inbound_plan_id = hash.key?('inboundPlanId') ? hash['inboundPlanId'] : nil
  last_updated_at = if hash.key?('lastUpdatedAt')
                      (DateTimeHelper.from_rfc3339(hash['lastUpdatedAt']) if hash['lastUpdatedAt'])
                    end
  marketplace_ids =
    hash.key?('marketplaceIds') ? hash['marketplaceIds'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  source_address = Address.from_hash(hash['sourceAddress']) if hash['sourceAddress']
  status = hash.key?('status') ? hash['status'] : nil
  # Parameter is an array, so we need to iterate through it
  packing_options = nil
  unless hash['packingOptions'].nil?
    packing_options = []
    hash['packingOptions'].each do |structure|
      packing_options << (PackingOptionSummary.from_hash(structure) if structure)
    end
  end

  packing_options = SKIP unless hash.key?('packingOptions')
  # Parameter is an array, so we need to iterate through it
  placement_options = nil
  unless hash['placementOptions'].nil?
    placement_options = []
    hash['placementOptions'].each do |structure|
      placement_options << (PlacementOptionSummary.from_hash(structure) if structure)
    end
  end

  placement_options = SKIP unless hash.key?('placementOptions')
  # Parameter is an array, so we need to iterate through it
  shipments = nil
  unless hash['shipments'].nil?
    shipments = []
    hash['shipments'].each do |structure|
      shipments << (ShipmentSummary.from_hash(structure) if structure)
    end
  end

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

  # 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.
  InboundPlan.new(created_at: created_at,
                  inbound_plan_id: inbound_plan_id,
                  last_updated_at: last_updated_at,
                  marketplace_ids: marketplace_ids,
                  name: name,
                  source_address: source_address,
                  status: status,
                  packing_options: packing_options,
                  placement_options: placement_options,
                  shipments: shipments,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 60

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['created_at'] = 'createdAt'
  @_hash['inbound_plan_id'] = 'inboundPlanId'
  @_hash['last_updated_at'] = 'lastUpdatedAt'
  @_hash['marketplace_ids'] = 'marketplaceIds'
  @_hash['name'] = 'name'
  @_hash['packing_options'] = 'packingOptions'
  @_hash['placement_options'] = 'placementOptions'
  @_hash['shipments'] = 'shipments'
  @_hash['source_address'] = 'sourceAddress'
  @_hash['status'] = 'status'
  @_hash
end

.nullablesObject

An array for nullable fields



85
86
87
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 85

def self.nullables
  []
end

.optionalsObject

An array for optional fields



76
77
78
79
80
81
82
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 76

def self.optionals
  %w[
    packing_options
    placement_options
    shipments
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



197
198
199
200
201
202
203
204
205
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 197

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at.inspect}, inbound_plan_id:"\
  " #{@inbound_plan_id.inspect}, last_updated_at: #{@last_updated_at.inspect},"\
  " marketplace_ids: #{@marketplace_ids.inspect}, name: #{@name.inspect}, packing_options:"\
  " #{@packing_options.inspect}, placement_options: #{@placement_options.inspect}, shipments:"\
  " #{@shipments.inspect}, source_address: #{@source_address.inspect}, status:"\
  " #{@status.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_atObject



178
179
180
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 178

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_last_updated_atObject



182
183
184
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 182

def to_custom_last_updated_at
  DateTimeHelper.to_rfc3339(last_updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



187
188
189
190
191
192
193
194
# File 'lib/walmart_ap_is/models/inbound_plan.rb', line 187

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at}, inbound_plan_id: #{@inbound_plan_id},"\
  " last_updated_at: #{@last_updated_at}, marketplace_ids: #{@marketplace_ids}, name:"\
  " #{@name}, packing_options: #{@packing_options}, placement_options: #{@placement_options},"\
  " shipments: #{@shipments}, source_address: #{@source_address}, status: #{@status},"\
  " additional_properties: #{@additional_properties}>"
end