system_hooks.rb 766 Bytes
Newer Older
Robert Schilling's avatar
Robert Schilling committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
module API
  module V3
    class SystemHooks < Grape::API
      before do
        authenticate!
        authenticated_as_admin!
      end

      resource :hooks do
        desc 'Get the list of system hooks' do
          success ::API::Entities::Hook
        end
        get do
          present SystemHook.all, with: ::API::Entities::Hook
        end
Robert Schilling's avatar
Robert Schilling committed
16 17 18 19 20 21 22 23 24 25 26 27 28

        desc 'Delete a hook' do
          success ::API::Entities::Hook
        end
        params do
          requires :id, type: Integer, desc: 'The ID of the system hook'
        end
        delete ":id" do
          hook = SystemHook.find_by(id: params[:id])
          not_found!('System hook') unless hook

          present hook.destroy, with: ::API::Entities::Hook
        end
Robert Schilling's avatar
Robert Schilling committed
29 30 31 32
      end
    end
  end
end