Class: FreightFinancialsWebhookIngestionApi::RatingResponseFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/freight_financials_webhook_ingestion_api/models/rating_response_format.rb

Overview

RatingResponseFormat.

Constant Summary collapse

RATING_RESPONSE_FORMAT =
[
  # TODO: Write general description for TEXT
  TEXT = 'Text'.freeze,

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = TEXT) ⇒ Object



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

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

  str = value.to_s.strip

  case str.downcase
  when 'text' then TEXT
  when 'json' then JSON
  when 'xml' then XML
  else
    default_value
  end
end

.validate(value) ⇒ Object



20
21
22
23
24
# File 'lib/freight_financials_webhook_ingestion_api/models/rating_response_format.rb', line 20

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

  RATING_RESPONSE_FORMAT.include?(value)
end