Class: WalmartApIs::WfsInventoryInsights

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

Overview

Demand intelligence and replenishment recommendations (WFS-only — no SP-API equivalent)

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(sales_forecast_week1to4: SKIP, sales_forecast_week5to8: SKIP, sales_forecast_week9to12: SKIP, sell_through_rate: SKIP, days_of_supply: SKIP, out_of_stock_date: SKIP, suggested_units: SKIP, surplus_units: SKIP, customer_favorite: SKIP, additional_properties: nil) ⇒ WfsInventoryInsights

Returns a new instance of WfsInventoryInsights.



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

def initialize(sales_forecast_week1to4: SKIP, sales_forecast_week5to8: SKIP,
               sales_forecast_week9to12: SKIP, sell_through_rate: SKIP,
               days_of_supply: SKIP, out_of_stock_date: SKIP,
               suggested_units: SKIP, surplus_units: SKIP,
               customer_favorite: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @sales_forecast_week1to4 = sales_forecast_week1to4 unless sales_forecast_week1to4 == SKIP
  @sales_forecast_week5to8 = sales_forecast_week5to8 unless sales_forecast_week5to8 == SKIP
  @sales_forecast_week9to12 = sales_forecast_week9to12 unless sales_forecast_week9to12 == SKIP
  @sell_through_rate = sell_through_rate unless sell_through_rate == SKIP
  @days_of_supply = days_of_supply unless days_of_supply == SKIP
  @out_of_stock_date = out_of_stock_date unless out_of_stock_date == SKIP
  @suggested_units = suggested_units unless suggested_units == SKIP
  @surplus_units = surplus_units unless surplus_units == SKIP
  @customer_favorite = customer_favorite unless customer_favorite == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#customer_favoriteTrueClass | FalseClass

Whether this item is flagged as a customer favorite

Returns:

  • (TrueClass | FalseClass)


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

def customer_favorite
  @customer_favorite
end

#days_of_supplyString

Estimated days until stock exhaustion at current sell rate

Returns:

  • (String)


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

def days_of_supply
  @days_of_supply
end

#out_of_stock_dateDate

Projected date of stock exhaustion

Returns:

  • (Date)


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

def out_of_stock_date
  @out_of_stock_date
end

#sales_forecast_week1to4Float

Estimated units to sell in weeks 1–4

Returns:

  • (Float)


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

def sales_forecast_week1to4
  @sales_forecast_week1to4
end

#sales_forecast_week5to8Float

Estimated units to sell in weeks 5–8

Returns:

  • (Float)


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

def sales_forecast_week5to8
  @sales_forecast_week5to8
end

#sales_forecast_week9to12Float

Estimated units to sell in weeks 9–12

Returns:

  • (Float)


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

def sales_forecast_week9to12
  @sales_forecast_week9to12
end

#sell_through_rateFloat

Units shipped ÷ average stored, last 90 days

Returns:

  • (Float)


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

def sell_through_rate
  @sell_through_rate
end

#suggested_unitsInteger

Walmart-recommended reorder quantity

Returns:

  • (Integer)


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

def suggested_units
  @suggested_units
end

#surplus_unitsInteger

Units exceeding 180 days of supply

Returns:

  • (Integer)


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

def surplus_units
  @surplus_units
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  sales_forecast_week1to4 =
    hash.key?('salesForecastWeek1to4') ? hash['salesForecastWeek1to4'] : SKIP
  sales_forecast_week5to8 =
    hash.key?('salesForecastWeek5to8') ? hash['salesForecastWeek5to8'] : SKIP
  sales_forecast_week9to12 =
    hash.key?('salesForecastWeek9to12') ? hash['salesForecastWeek9to12'] : SKIP
  sell_through_rate =
    hash.key?('sellThroughRate') ? hash['sellThroughRate'] : SKIP
  days_of_supply = hash.key?('daysOfSupply') ? hash['daysOfSupply'] : SKIP
  out_of_stock_date =
    hash.key?('outOfStockDate') ? hash['outOfStockDate'] : SKIP
  suggested_units =
    hash.key?('suggestedUnits') ? hash['suggestedUnits'] : SKIP
  surplus_units = hash.key?('surplusUnits') ? hash['surplusUnits'] : SKIP
  customer_favorite =
    hash.key?('customerFavorite') ? hash['customerFavorite'] : 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.
  WfsInventoryInsights.new(sales_forecast_week1to4: sales_forecast_week1to4,
                           sales_forecast_week5to8: sales_forecast_week5to8,
                           sales_forecast_week9to12: sales_forecast_week9to12,
                           sell_through_rate: sell_through_rate,
                           days_of_supply: days_of_supply,
                           out_of_stock_date: out_of_stock_date,
                           suggested_units: suggested_units,
                           surplus_units: surplus_units,
                           customer_favorite: customer_favorite,
                           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/wfs_inventory_insights.rb', line 50

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['sales_forecast_week1to4'] = 'salesForecastWeek1to4'
  @_hash['sales_forecast_week5to8'] = 'salesForecastWeek5to8'
  @_hash['sales_forecast_week9to12'] = 'salesForecastWeek9to12'
  @_hash['sell_through_rate'] = 'sellThroughRate'
  @_hash['days_of_supply'] = 'daysOfSupply'
  @_hash['out_of_stock_date'] = 'outOfStockDate'
  @_hash['suggested_units'] = 'suggestedUnits'
  @_hash['surplus_units'] = 'surplusUnits'
  @_hash['customer_favorite'] = 'customerFavorite'
  @_hash
end

.nullablesObject

An array for nullable fields



80
81
82
83
84
85
86
87
88
# File 'lib/walmart_ap_is/models/wfs_inventory_insights.rb', line 80

def self.nullables
  %w[
    sales_forecast_week1to4
    sales_forecast_week5to8
    sales_forecast_week9to12
    out_of_stock_date
    surplus_units
  ]
end

.optionalsObject

An array for optional fields



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/walmart_ap_is/models/wfs_inventory_insights.rb', line 65

def self.optionals
  %w[
    sales_forecast_week1to4
    sales_forecast_week5to8
    sales_forecast_week9to12
    sell_through_rate
    days_of_supply
    out_of_stock_date
    suggested_units
    surplus_units
    customer_favorite
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



164
165
166
167
168
169
170
171
172
173
# File 'lib/walmart_ap_is/models/wfs_inventory_insights.rb', line 164

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} sales_forecast_week1to4: #{@sales_forecast_week1to4.inspect},"\
  " sales_forecast_week5to8: #{@sales_forecast_week5to8.inspect}, sales_forecast_week9to12:"\
  " #{@sales_forecast_week9to12.inspect}, sell_through_rate: #{@sell_through_rate.inspect},"\
  " days_of_supply: #{@days_of_supply.inspect}, out_of_stock_date:"\
  " #{@out_of_stock_date.inspect}, suggested_units: #{@suggested_units.inspect},"\
  " surplus_units: #{@surplus_units.inspect}, customer_favorite:"\
  " #{@customer_favorite.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



153
154
155
156
157
158
159
160
161
# File 'lib/walmart_ap_is/models/wfs_inventory_insights.rb', line 153

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} sales_forecast_week1to4: #{@sales_forecast_week1to4},"\
  " sales_forecast_week5to8: #{@sales_forecast_week5to8}, sales_forecast_week9to12:"\
  " #{@sales_forecast_week9to12}, sell_through_rate: #{@sell_through_rate}, days_of_supply:"\
  " #{@days_of_supply}, out_of_stock_date: #{@out_of_stock_date}, suggested_units:"\
  " #{@suggested_units}, surplus_units: #{@surplus_units}, customer_favorite:"\
  " #{@customer_favorite}, additional_properties: #{@additional_properties}>"
end