Class: Api::V1::LiveEventsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/api/v1/live_events_controller.rb

Instance Method Summary collapse

Instance Method Details

#process_eventObject

rubocop:disable Metrics/AbcSize



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/api/v1/live_events_controller.rb', line 4

def process_event # rubocop:disable Metrics/AbcSize
  payload = SymmetricEncryption.decrypt(params[:payload])
  payload = JSON.parse(payload)
  Rails.logger.debug("Processing event type: #{payload['attributes']['event_name']}")
  Rails.logger.debug("Payload: #{payload}")
  event = "LiveEvents::#{payload['attributes']['event_name'].camelcase}Event".constantize
  event.perform_later(payload)
  head :ok
rescue => e # rubocop:disable Style/RescueStandardError
  Rails.logger.error("Live Events Error: #{e.message} - #{e.backtrace}")
  render json: { error: "Live Events Error: #{e.message}" }, status: 422
end