Class: WalmartApIs::StockStatus
- Inherits:
-
Object
- Object
- WalmartApIs::StockStatus
- Defined in:
- lib/walmart_ap_is/models/stock_status.rb
Overview
Stock health label based on days of supply
Constant Summary collapse
- STOCK_STATUS =
[ # TODO: Write general description for INSTOCK INSTOCK = 'InStock'.freeze, # TODO: Write general description for ATRISK ATRISK = 'AtRisk'.freeze, # TODO: Write general description for OUTOFSTOCK OUTOFSTOCK = 'OutOfStock'.freeze, # TODO: Write general description for LONGTERMOUTOFSTOCK LONGTERMOUTOFSTOCK = 'LongTermOutOfStock'.freeze, # TODO: Write general description for NEWTOWFS NEWTOWFS = 'NewToWfs'.freeze ].freeze
Class Method Summary collapse
Class Method Details
.from_value(value, default_value = INSTOCK) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/walmart_ap_is/models/stock_status.rb', line 32 def self.from_value(value, default_value = INSTOCK) return default_value if value.nil? str = value.to_s.strip case str.downcase when 'instock' then INSTOCK when 'atrisk' then ATRISK when 'outofstock' then OUTOFSTOCK when 'longtermoutofstock' then LONGTERMOUTOFSTOCK when 'newtowfs' then NEWTOWFS else default_value end end |
.validate(value) ⇒ Object
26 27 28 29 30 |
# File 'lib/walmart_ap_is/models/stock_status.rb', line 26 def self.validate(value) return false if value.nil? STOCK_STATUS.include?(value) end |