Sha256: 764672b7bf85659c4c5ef94a280cf728985a4dd6ccf3335ad78d5ff6d77b8882

Contents?: true

Size: 1.06 KB

Versions: 10

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true
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

10 entries across 10 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.38.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.37.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.36.1 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.36.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.35.1 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.35.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.34.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.33.0 app/controllers/shipit/api/hooks_controller.rb
shipit-engine-0.32.0 app/controllers/shipit/api/hooks_controller.rb