Class: WalmartApIs::WfsInventoryData

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

Overview

WfsInventoryData 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(publishing_status: SKIP, item_lifecycle: SKIP, stock_status: SKIP, fulfillable_quantity: SKIP, reserved_quantity: SKIP, inbound_quantity: SKIP, on_hand_quantity: SKIP, unavailable_quantity: SKIP, inventory_age: SKIP, first_in_stock_date: SKIP, additional_properties: nil) ⇒ WfsInventoryData

Returns a new instance of WfsInventoryData.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/walmart_ap_is/models/wfs_inventory_data.rb', line 94

def initialize(publishing_status: SKIP, item_lifecycle: SKIP,
               stock_status: SKIP, fulfillable_quantity: SKIP,
               reserved_quantity: SKIP, inbound_quantity: SKIP,
               on_hand_quantity: SKIP, unavailable_quantity: SKIP,
               inventory_age: SKIP, first_in_stock_date: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @publishing_status = publishing_status unless publishing_status == SKIP
  @item_lifecycle = item_lifecycle unless item_lifecycle == SKIP
  @stock_status = stock_status unless stock_status == SKIP
  @fulfillable_quantity = fulfillable_quantity unless fulfillable_quantity == SKIP
  @reserved_quantity = reserved_quantity unless reserved_quantity == SKIP
  @inbound_quantity = inbound_quantity unless inbound_quantity == SKIP
  @on_hand_quantity = on_hand_quantity unless on_hand_quantity == SKIP
  @unavailable_quantity = unavailable_quantity unless unavailable_quantity == SKIP
  @inventory_age = inventory_age unless inventory_age == SKIP
  @first_in_stock_date = first_in_stock_date unless first_in_stock_date == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#first_in_stock_dateDate

Date item first arrived at a WFS fulfillment center

Returns:

  • (Date)


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

def first_in_stock_date
  @first_in_stock_date
end

#fulfillable_quantityInteger

Units available to sell (SP-API aligned — fulfillableQuantity)

Returns:

  • (Integer)


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

def fulfillable_quantity
  @fulfillable_quantity
end

#inbound_quantityInteger

Total units in transit to WFS fulfillment centers

Returns:

  • (Integer)


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

def inbound_quantity
  @inbound_quantity
end

#inventory_ageWfsInventoryAge

Units grouped by storage duration. Used for long-term storage fee assessment. 7 buckets: days365Plus, days365To450, and days450Plus reflect the upstream split-aged-buckets feature — days365Plus is the pre-split total.

Returns:



49
50
51
# File 'lib/walmart_ap_is/models/wfs_inventory_data.rb', line 49

def inventory_age
  @inventory_age
end

#item_lifecycleItemLifecycle

Lifecycle state in the Walmart catalog

Returns:



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

def item_lifecycle
  @item_lifecycle
end

#on_hand_quantityInteger

Total on-hand units (fulfillable + reserved + unavailable)

Returns:

  • (Integer)


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

def on_hand_quantity
  @on_hand_quantity
end

#publishing_statusPublishingStatus

Current listing state of the item

Returns:



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

def publishing_status
  @publishing_status
end

#reserved_quantityWfsReservedQuantity

Reserved inventory breakdown (SP-API-aligned naming)

Returns:



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

def reserved_quantity
  @reserved_quantity
end

#stock_statusStockStatus

Stock health label based on days of supply

Returns:



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

def stock_status
  @stock_status
end

#unavailable_quantityWfsUnavailableQuantity

Total on-hand units (fulfillable + reserved + unavailable)



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

def unavailable_quantity
  @unavailable_quantity
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/walmart_ap_is/models/wfs_inventory_data.rb', line 117

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  publishing_status =
    hash.key?('publishingStatus') ? hash['publishingStatus'] : SKIP
  item_lifecycle = hash.key?('itemLifecycle') ? hash['itemLifecycle'] : SKIP
  stock_status = hash.key?('stockStatus') ? hash['stockStatus'] : SKIP
  fulfillable_quantity =
    hash.key?('fulfillableQuantity') ? hash['fulfillableQuantity'] : SKIP
  reserved_quantity = WfsReservedQuantity.from_hash(hash['reservedQuantity']) if
    hash['reservedQuantity']
  inbound_quantity =
    hash.key?('inboundQuantity') ? hash['inboundQuantity'] : SKIP
  on_hand_quantity =
    hash.key?('onHandQuantity') ? hash['onHandQuantity'] : SKIP
  unavailable_quantity = WfsUnavailableQuantity.from_hash(hash['unavailableQuantity']) if
    hash['unavailableQuantity']
  inventory_age = WfsInventoryAge.from_hash(hash['inventoryAge']) if hash['inventoryAge']
  first_in_stock_date =
    hash.key?('firstInStockDate') ? hash['firstInStockDate'] : 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.
  WfsInventoryData.new(publishing_status: publishing_status,
                       item_lifecycle: item_lifecycle,
                       stock_status: stock_status,
                       fulfillable_quantity: fulfillable_quantity,
                       reserved_quantity: reserved_quantity,
                       inbound_quantity: inbound_quantity,
                       on_hand_quantity: on_hand_quantity,
                       unavailable_quantity: unavailable_quantity,
                       inventory_age: inventory_age,
                       first_in_stock_date: first_in_stock_date,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['publishing_status'] = 'publishingStatus'
  @_hash['item_lifecycle'] = 'itemLifecycle'
  @_hash['stock_status'] = 'stockStatus'
  @_hash['fulfillable_quantity'] = 'fulfillableQuantity'
  @_hash['reserved_quantity'] = 'reservedQuantity'
  @_hash['inbound_quantity'] = 'inboundQuantity'
  @_hash['on_hand_quantity'] = 'onHandQuantity'
  @_hash['unavailable_quantity'] = 'unavailableQuantity'
  @_hash['inventory_age'] = 'inventoryAge'
  @_hash['first_in_stock_date'] = 'firstInStockDate'
  @_hash
end

.nullablesObject

An array for nullable fields



88
89
90
91
92
# File 'lib/walmart_ap_is/models/wfs_inventory_data.rb', line 88

def self.nullables
  %w[
    first_in_stock_date
  ]
end

.optionalsObject

An array for optional fields



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/walmart_ap_is/models/wfs_inventory_data.rb', line 72

def self.optionals
  %w[
    publishing_status
    item_lifecycle
    stock_status
    fulfillable_quantity
    reserved_quantity
    inbound_quantity
    on_hand_quantity
    unavailable_quantity
    inventory_age
    first_in_stock_date
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



172
173
174
175
176
177
178
179
180
181
# File 'lib/walmart_ap_is/models/wfs_inventory_data.rb', line 172

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} publishing_status: #{@publishing_status.inspect}, item_lifecycle:"\
  " #{@item_lifecycle.inspect}, stock_status: #{@stock_status.inspect}, fulfillable_quantity:"\
  " #{@fulfillable_quantity.inspect}, reserved_quantity: #{@reserved_quantity.inspect},"\
  " inbound_quantity: #{@inbound_quantity.inspect}, on_hand_quantity:"\
  " #{@on_hand_quantity.inspect}, unavailable_quantity: #{@unavailable_quantity.inspect},"\
  " inventory_age: #{@inventory_age.inspect}, first_in_stock_date:"\
  " #{@first_in_stock_date.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} publishing_status: #{@publishing_status}, item_lifecycle:"\
  " #{@item_lifecycle}, stock_status: #{@stock_status}, fulfillable_quantity:"\
  " #{@fulfillable_quantity}, reserved_quantity: #{@reserved_quantity}, inbound_quantity:"\
  " #{@inbound_quantity}, on_hand_quantity: #{@on_hand_quantity}, unavailable_quantity:"\
  " #{@unavailable_quantity}, inventory_age: #{@inventory_age}, first_in_stock_date:"\
  " #{@first_in_stock_date}, additional_properties: #{@additional_properties}>"
end