Class: SmSmsCampaignWebhook::WebhookController

Inherits:
ApplicationController show all
Defined in:
app/controllers/sm_sms_campaign_webhook/webhook_controller.rb

Overview

API webhook for POST requests from SMS campaign service.

Instance Method Summary collapse

Instance Method Details

#createObject

POST /api/webhook



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/sm_sms_campaign_webhook/webhook_controller.rb', line 11

def create
  # Deserialize the payload.
  payload = JSON.parse(request.body.read)
  logger.debug "#{self.class} - Payload: #{payload.inspect}"

  # Dispatch the payload to the appropriate payload processor.
  DispatchPayloadJob.perform_later(payload)

  head :no_content
rescue JSON::ParserError => e
  logger.warn "#{self.class} - Bad Request: #{e.class} - #{e}"
  head :bad_request
end