Chatwoot/lib/webhooks/twitter.rb
Pranav Raj S 272c481464
Feature: Create conversations from Tweets (#470)
* Feature: Add tweets to conversations
2020-02-09 15:47:48 +05:30

29 lines
592 B
Ruby

# frozen_string_literal: true
class Webhooks::Twitter
SUPPORTED_EVENTS = [:direct_message_events, :tweet_create_events].freeze
attr_accessor :params, :account
def initialize(params)
@params = params
end
def consume
send(event_name) if event_name
end
private
def event_name
@event_name ||= SUPPORTED_EVENTS.find { |key| @params.key?(key.to_s) }
end
def direct_message_events
::Twitter::DirectMessageParserService.new(payload: @params).perform
end
def tweet_create_events
::Twitter::TweetParserService.new(payload: @params).perform
end
end