Class: WalmartApIs::ReasonCode

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

Overview

ReasonCode.

Constant Summary collapse

REASON_CODE =
[
  # TODO: Write general description for APPROVAL_REQUIRED
  APPROVAL_REQUIRED = 'APPROVAL_REQUIRED'.freeze,

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

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

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

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = APPROVAL_REQUIRED) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/walmart_ap_is/models/reason_code.rb', line 41

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

  str = value.to_s.strip

  case str.downcase
  when 'approval_required' then APPROVAL_REQUIRED
  when 'asin_not_applicable' then ASIN_NOT_APPLICABLE
  when 'not_eligible' then NOT_ELIGIBLE
  when 'ineligible_item_condition' then INELIGIBLE_ITEM_CONDITION
  when 'compliance_blocked' then COMPLIANCE_BLOCKED
  when 'hazmat' then HAZMAT
  when 'recalled' then RECALLED
  when 'restricted_category' then RESTRICTED_CATEGORY
  else
    default_value
  end
end

.validate(value) ⇒ Object



35
36
37
38
39
# File 'lib/walmart_ap_is/models/reason_code.rb', line 35

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

  REASON_CODE.include?(value)
end