Sha256: 7f1614fb4ff12d2c3f69f55ea16816c8ecd33ab708253090afe866650a7a9484

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

module SlackRubyBotServer
  module Events
    module Api
      module Endpoints
        module Slack
          class ActionsEndpoint < Grape::API
            desc 'Respond to interactive slack buttons and actions.'
            params do
              requires :payload, type: JSON do
                requires :token, type: String
                requires :callback_id, type: String
                optional :type, type: String
                optional :trigger_id, type: String
                optional :response_url, type: String
                requires :channel, type: Hash do
                  requires :id, type: String
                  optional :name, type: String
                end
                requires :user, type: Hash do
                  requires :id, type: String
                  optional :name, type: String
                end
                requires :team, type: Hash do
                  requires :id, type: String
                  optional :domain, type: String
                end
                optional :actions, type: Array do
                  requires :value, type: String
                end
                optional :message, type: Hash do
                  requires :type, type: String
                  requires :user, type: String
                  requires :ts, type: String
                  requires :text, type: String
                end
              end
            end
            post '/action' do
              action = SlackRubyBotServer::Events::Requests::Action.new(params, request)
              callback_id = params[:payload][:callback_id]
              SlackRubyBotServer::Events.config.run_callbacks(:action, callback_id, action) || body(false)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack-ruby-bot-server-events-0.1.0 lib/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint.rb