2020-04-10 11:12:37 +00:00
|
|
|
class Api::V1::Widget::EventsController < Api::V1::Widget::BaseController
|
|
|
|
include Events::Types
|
|
|
|
|
|
|
|
def create
|
2021-05-03 14:53:09 +00:00
|
|
|
Rails.configuration.dispatcher.dispatch(permitted_params[:name], Time.zone.now, contact_inbox: @contact_inbox,
|
|
|
|
event_info: permitted_params[:event_info].to_h.merge(event_info))
|
2020-04-10 11:12:37 +00:00
|
|
|
head :no_content
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-06-12 18:49:43 +00:00
|
|
|
def event_info
|
|
|
|
{
|
|
|
|
widget_language: params[:locale],
|
2020-07-20 12:58:14 +00:00
|
|
|
browser_language: browser.accept_language.first&.code,
|
|
|
|
browser: browser_params
|
2020-06-12 18:49:43 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-04-10 11:12:37 +00:00
|
|
|
def permitted_params
|
2021-05-03 14:53:09 +00:00
|
|
|
params.permit(:name, :website_token, event_info: {})
|
2020-04-10 11:12:37 +00:00
|
|
|
end
|
|
|
|
end
|