Class: WalmartApIs::ConditionType2

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

Overview

Indicates the condition of the item. Possible values: New, Used, Collectible, Refurbished, Club.

Constant Summary collapse

CONDITION_TYPE2 =
[
  # TODO: Write general description for NEW
  NEW = 'New'.freeze,

  # TODO: Write general description for USED
  USED = 'Used'.freeze,

  # TODO: Write general description for COLLECTIBLE
  COLLECTIBLE = 'Collectible'.freeze,

  # TODO: Write general description for REFURBISHED
  REFURBISHED = 'Refurbished'.freeze,

  # TODO: Write general description for CLUB
  CLUB = 'Club'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = NEW) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/walmart_ap_is/models/condition_type2.rb', line 33

def self.from_value(value, default_value = NEW)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'new' then NEW
  when 'used' then USED
  when 'collectible' then COLLECTIBLE
  when 'refurbished' then REFURBISHED
  when 'club' then CLUB
  else
    default_value
  end
end

.validate(value) ⇒ Object



27
28
29
30
31
# File 'lib/walmart_ap_is/models/condition_type2.rb', line 27

def self.validate(value)
  return false if value.nil?

  CONDITION_TYPE2.include?(value)
end