Module: Facebook::Messenger::Incoming
- Defined in:
- lib/facebook/messenger/incoming.rb,
lib/facebook/messenger/incoming/read.rb,
lib/facebook/messenger/incoming/optin.rb,
lib/facebook/messenger/incoming/common.rb,
lib/facebook/messenger/incoming/message.rb,
lib/facebook/messenger/incoming/payment.rb,
lib/facebook/messenger/incoming/delivery.rb,
lib/facebook/messenger/incoming/postback.rb,
lib/facebook/messenger/incoming/referral.rb,
lib/facebook/messenger/incoming/game_play.rb,
lib/facebook/messenger/incoming/message_echo.rb,
lib/facebook/messenger/incoming/account_linking.rb,
lib/facebook/messenger/incoming/message_request.rb,
lib/facebook/messenger/incoming/message_reaction.rb,
lib/facebook/messenger/incoming/policy_enforcement.rb,
lib/facebook/messenger/incoming/pass_thread_control.rb
Overview
Module Incoming parses and abstracts incoming requests from Messenger.
Defined Under Namespace
Modules: Common Classes: AccountLinking, Delivery, GamePlay, Message, MessageEcho, MessageReaction, MessageRequest, Optin, PassThreadControl, Payment, PolicyEnforcement, Postback, Read, Referral, UnknownPayload
Constant Summary collapse
- EVENTS =
Returns Hash containing facebook messenger events and its event handler classes.
{ 'message' => Message, 'delivery' => Delivery, 'postback' => Postback, 'optin' => Optin, 'read' => Read, 'account_linking' => AccountLinking, 'referral' => Referral, 'message_echo' => MessageEcho, 'message_request' => MessageRequest, 'payment' => Payment, 'policy_enforcement' => PolicyEnforcement, 'pass_thread_control' => PassThreadControl, 'game_play' => GamePlay, 'reaction' => MessageReaction }.freeze
Class Method Summary collapse
-
.parse(payload) ⇒ Object
Parse the given payload and create new object of class related to event in payload.
-
.payload_is_echo?(payload) ⇒ Boolean
Check if event is echo.
Class Method Details
.parse(payload) ⇒ Object
Parse the given payload and create new object of class related
to event in payload.
53 54 55 56 57 58 59 60 61 |
# File 'lib/facebook/messenger/incoming.rb', line 53 def self.parse(payload) return MessageEcho.new(payload) if payload_is_echo?(payload) EVENTS.each do |event, klass| return klass.new(payload) if payload.key?(event) end raise UnknownPayload, payload end |
.payload_is_echo?(payload) ⇒ Boolean
Check if event is echo.
70 71 72 |
# File 'lib/facebook/messenger/incoming.rb', line 70 def self.payload_is_echo?(payload) payload.key?('message') && payload['message']['is_echo'] == true end |