Sha256: aa3039693b798a9cb71b7b90b24448980d14c200b39ad8b3a114818d491e7072

Contents?: true

Size: 881 Bytes

Versions: 33

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true
module ShopifyApp
  class MissingWebhookJobError < StandardError; end

  class WebhooksController < ActionController::Base
    include ShopifyApp::WebhookVerification

    def receive
      params.permit!
      job_args = { shop_domain: shop_domain, webhook: webhook_params.to_h }
      webhook_job_klass.perform_later(job_args)
      head(:ok)
    end

    private

    def webhook_params
      params.except(:controller, :action, :type)
    end

    def webhook_job_klass
      webhook_job_klass_name.safe_constantize || raise(ShopifyApp::MissingWebhookJobError)
    end

    def webhook_job_klass_name(type = webhook_type)
      [webhook_namespace, "#{type}_job"].compact.join('/').classify
    end

    def webhook_type
      params[:type]
    end

    def webhook_namespace
      ShopifyApp.configuration.webhook_jobs_namespace
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
shopify_app-18.0.4 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-18.0.3 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-18.0.2 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-18.0.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-18.0.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.2.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.2.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.1.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.1.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.0.5 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.0.4 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.0.3 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.0.2 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.0.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-17.0.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-16.1.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-16.0.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-15.0.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-15.0.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-14.4.4 app/controllers/shopify_app/webhooks_controller.rb