Chatwoot/app/controllers/api/v1/widget/inboxes_controller.rb
Pranav Raj S 7b63cbe1f7 [Enhancement] Select widget_color while creating inbox (#362)
* [Enhancement] Select widget_color while creating inbox

* Fix codeclimate issues

* Fix !important
2019-12-14 18:14:35 +05:30

32 lines
741 B
Ruby

class Api::V1::Widget::InboxesController < Api::BaseController
before_action :authorize_request
def create
ActiveRecord::Base.transaction do
channel = web_widgets.create!(
website_name: permitted_params[:website_name],
website_url: permitted_params[:website_url],
widget_color: permitted_params[:widget_color]
)
@inbox = inboxes.create!(name: permitted_params[:website_name], channel: channel)
end
end
private
def authorize_request
authorize ::Inbox
end
def inboxes
current_account.inboxes
end
def web_widgets
current_account.web_widgets
end
def permitted_params
params.fetch(:website).permit(:website_name, :website_url, :widget_color)
end
end