Chatwoot/app/controllers/api/v1/widget/events_controller.rb
Sojan Jose 98e2a9b8b5
feat: Builder for creating Campaign conversations (#2192)
- Builder for creating Campaign conversations
- Widget endpoint to fetch the campaigns
2021-05-03 20:23:09 +05:30

23 lines
673 B
Ruby

class Api::V1::Widget::EventsController < Api::V1::Widget::BaseController
include Events::Types
def create
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))
head :no_content
end
private
def event_info
{
widget_language: params[:locale],
browser_language: browser.accept_language.first&.code,
browser: browser_params
}
end
def permitted_params
params.permit(:name, :website_token, event_info: {})
end
end