Module: SlackBot::Events::Schematize

Defined in:
lib/slack_bot/events/schematize.rb

Class Method Summary collapse

Class Method Details

.call(data:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/slack_bot/events/schematize.rb', line 15

def self.call(data:)
  parsed_data = JSON.parse(data)
  return { parsed_data: parsed_data } unless schema_klass = message(parsed_data)

  if schema_klass.respond_to?(:call)
    { schema: schema_klass.call(parsed_data).new(parsed_data), parsed_data: parsed_data }
  else
    { schema: schema_klass.new(parsed_data), parsed_data: parsed_data }
  end
end

.message(parsed_data) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/slack_bot/events/schematize.rb', line 6

def self.message(parsed_data)
  case parsed_data["type"]
  when "events_api"
    return SlackBot::Events::Schemas::SocketPayload
  when "app_rate_limited"
  when "hello"
  end
end