Class: WalmartApIs::Requirements

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

Overview

Requirements.

Constant Summary collapse

REQUIREMENTS =
[
  # TODO: Write general description for LISTING
  LISTING = 'LISTING'.freeze,

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = LISTING) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/walmart_ap_is/models/requirements.rb', line 26

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

  str = value.to_s.strip

  case str.downcase
  when 'listing' then LISTING
  when 'listing_product_only' then LISTING_PRODUCT_ONLY
  when 'listing_offer_only' then LISTING_OFFER_ONLY
  else
    default_value
  end
end

.validate(value) ⇒ Object



20
21
22
23
24
# File 'lib/walmart_ap_is/models/requirements.rb', line 20

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

  REQUIREMENTS.include?(value)
end