2021-05-17 05:02:59 +00:00
|
|
|
class Api::V1::Accounts::Integrations::HooksController < Api::V1::Accounts::BaseController
|
|
|
|
before_action :fetch_hook, only: [:update, :destroy]
|
|
|
|
before_action :check_authorization
|
|
|
|
|
|
|
|
def create
|
|
|
|
@hook = Current.account.hooks.create!(permitted_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@hook.update!(permitted_params.slice(:status, :settings))
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2022-03-24 07:58:25 +00:00
|
|
|
@hook.destroy!
|
2021-05-17 05:02:59 +00:00
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_hook
|
|
|
|
@hook = Current.account.hooks.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_authorization
|
|
|
|
authorize(:hook)
|
|
|
|
end
|
|
|
|
|
|
|
|
def permitted_params
|
|
|
|
params.require(:hook).permit(:app_id, :inbox_id, :status, settings: {})
|
|
|
|
end
|
|
|
|
end
|