Class: Integrations::SlackEventService
- Inherits:
-
Object
- Object
- Integrations::SlackEventService
- Defined in:
- app/services/integrations/slack_event_service.rb
Constant Summary collapse
- URL_VERIFICATION_EVENT =
'url_verification'
- UnknownEventError =
Class.new(StandardError)
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(params) ⇒ SlackEventService
constructor
A new instance of SlackEventService.
Constructor Details
#initialize(params) ⇒ SlackEventService
Returns a new instance of SlackEventService.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/integrations/slack_event_service.rb', line 11 def initialize(params) # When receiving URL verification events, params[:type] is 'url_verification'. # For all other events we subscribe to, params[:type] is 'event_callback' and # the specific type of the event will be in params[:event][:type]. # Remove both of these from the params before they are passed to the services. type = params.delete(:type) type = params[:event].delete(:type) if type == 'event_callback' @slack_event = type @params = params end |
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/services/integrations/slack_event_service.rb', line 23 def execute raise UnknownEventError, "Unable to handle event type: '#{slack_event}'" unless routable_event? payload = route_event ServiceResponse.success(payload: payload) end |