Sha256: f2a031bbe5b5a3b5af86f6e24bd812f5414111eef6af4c227772db30525fa90f

Contents?: true

Size: 1.03 KB

Versions: 41

Compression:

Stored size: 1.03 KB

Contents

module Shipit
  module Api
    class HooksController < BaseController
      require_permission :read, :hook, only: %i(index show)
      require_permission :write, :hook, only: %i(create update destroy)

      def index
        render_resources hooks
      end

      def show
        render json: hook
      end

      params do
        requires :delivery_url, String
        requires :events, Array[String]
        accepts :content_type, String
      end
      def create
        render_resource hooks.create(params)
      end

      params do
        accepts :delivery_url, String
        accepts :events, Array[String]
        accepts :content_type, String
      end
      def update
        hook.update(params)
        render_resource hook
      end

      def destroy
        render_resource hook.destroy
      end

      private

      def hook
        hooks.find(params[:id])
      end

      def hooks
        Hook.where(stack_id: stack_id)
      end

      def stack_id
        stack.id if params[:stack_id].present?
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.30.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.29.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.28.1 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.28.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.27.1 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.27.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.26.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.25.1 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.25.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.24.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.23.1 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.23.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.22.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.21.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.20.1 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.20.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.19.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.18.1 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.18.0 app/controllers/shipit/api/hooks_controller.rb