Class: WalmartApIs::ContentType

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

Overview

MIME type of the uploaded feed content. If omitted, the server infers from the file's Content-Type in the multipart header.

Constant Summary collapse

CONTENT_TYPE =
[
  # TODO: Write general description for ENUM_TEXTXML_CHARSETUTF8
  ENUM_TEXTXML_CHARSETUTF8 = 'text/xml; charset=UTF-8'.freeze,

  # TODO: Write general description for
  # ENUM_TEXTTABSEPARATEDVALUES_CHARSETUTF8
  ENUM_TEXTTABSEPARATEDVALUES_CHARSETUTF8 = 'text/tab-separated-values; charset=UTF-8'.freeze,

  # TODO: Write general description for ENUM_APPLICATIONJSON_CHARSETUTF8
  ENUM_APPLICATIONJSON_CHARSETUTF8 = 'application/json; charset=UTF-8'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = ENUM_TEXTXML_CHARSETUTF8) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/walmart_ap_is/models/content_type.rb', line 28

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

  str = value.to_s.strip

  case str.downcase
  when 'enum_textxml_charsetutf8' then ENUM_TEXTXML_CHARSETUTF8
  when 'enum_texttabseparatedvalues_charsetutf8' then ENUM_TEXTTABSEPARATEDVALUES_CHARSETUTF8
  when 'enum_applicationjson_charsetutf8' then ENUM_APPLICATIONJSON_CHARSETUTF8
  else
    default_value
  end
end

.validate(value) ⇒ Object



22
23
24
25
26
# File 'lib/walmart_ap_is/models/content_type.rb', line 22

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

  CONTENT_TYPE.include?(value)
end