Module: Castle::Core::ProcessWebhook

Defined in:
lib/castle/core/process_webhook.rb

Overview

Parses a webhook

Class Method Summary collapse

Class Method Details

.call(webhook, config = nil) ⇒ String

Checks if webhook is valid

Parameters:

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
# File 'lib/castle/core/process_webhook.rb', line 12

def call(webhook, config = nil)
  webhook
    .body
    .read
    .tap do |result|
      raise Castle::ApiError, 'Invalid webhook from Castle API' if result.blank?

      Castle::Logger.call('webhook:', result.to_s, config)
    end
end