Sha256: 3f5576d9a2961669e9a735fced3d0cc38bc6ab50954901aaa1dc0f0f7a67fda3

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 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
                optional :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
                  optional :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)
              payload_type = params[:payload][:type]
              callback_id = params[:payload][:callback_id]
              SlackRubyBotServer::Events.config.run_callbacks(:action, [payload_type, callback_id].compact, 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.2.0 lib/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint.rb