Class: CalendarApi::ChannelType

Inherits:
Object
  • Object
show all
Defined in:
lib/calendar_api/models/channel_type.rb

Overview

The type of delivery mechanism used for the notification channel.

Constant Summary collapse

CHANNEL_TYPE =
[
  # TODO: Write general description for WEB_HOOK
  WEB_HOOK = 'web_hook'.freeze,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = WEB_HOOK) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/calendar_api/models/channel_type.rb', line 23

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

  str = value.to_s.strip

  case str.downcase
  when 'web_hook' then WEB_HOOK
  when 'webhook1' then WEBHOOK1
  else
    default_value
  end
end

.validate(value) ⇒ Object



17
18
19
20
21
# File 'lib/calendar_api/models/channel_type.rb', line 17

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

  CHANNEL_TYPE.include?(value)
end