Class: Keinaufwand::Sync::WebhooksController

Inherits:
ActionController::API
  • Object
show all
Defined in:
lib/keinaufwand/sync_core/webhooks_controller.rb

Instance Method Summary collapse

Instance Method Details

#receiveObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/keinaufwand/sync_core/webhooks_controller.rb', line 6

def receive
  payload = JSON.parse(request.raw_post)
  result = Sync.configuration.webhook_processor(payload).perform
  Rails.logger.info("[Keinaufwand::Sync] #{payload["event_type"]}: #{result}")
  head :ok
rescue JSON::ParserError
  head :bad_request
rescue WebhookProcessor::InvalidPayload => error
  Rails.logger.warn("[Keinaufwand::Sync] #{error.message}")
  head :unprocessable_entity
rescue StandardError => error
  Rails.logger.error("[Keinaufwand::Sync] #{error.class}: #{error.message}")
  head :unprocessable_entity
end