Class: NinjaVanApi::WebhooksController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/ninja_van_api/webhooks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/ninja_van_api/webhooks_controller.rb', line 5

def create
  if NinjaVanApi.configuration.webhook_job_class
    klass =
      begin
        NinjaVanApi.configuration.webhook_job_class.constantize
      rescue NameError
        raise ArgumentError,
              "webhook_job_class must be an ActiveJob class name or class that responds to perform_later"
      end

    klass.perform_later(webhook_params.to_h)
    head :ok
  else
    head :unprocessable_entity
  end
end