* Fix webhook API and add POST /api/webhooks docs
* Document GET /api/webhooks/:id
* Fix DELETE /api/webhooks/{id} and document it
* Add proper 404 specs
31 lines
718 B
Ruby
31 lines
718 B
Ruby
module Api
|
|
module V0
|
|
class WebhooksController < ApiController
|
|
respond_to :json
|
|
before_action :authenticate!
|
|
|
|
skip_before_action :verify_authenticity_token, only: %w[create destroy]
|
|
|
|
def create
|
|
@webhook = @user.webhook_endpoints.create!(webhook_params)
|
|
render "show", status: :created
|
|
end
|
|
|
|
def show
|
|
@webhook = @user.webhook_endpoints.find(params[:id])
|
|
end
|
|
|
|
def destroy
|
|
webhook = @user.webhook_endpoints.find(params[:id])
|
|
webhook.destroy!
|
|
head :no_content
|
|
end
|
|
|
|
private
|
|
|
|
def webhook_params
|
|
params.require(:webhook_endpoint).permit(:target_url, :source, events: [])
|
|
end
|
|
end
|
|
end
|
|
end
|