Sha256: 73f694992e2667d110f56341cdeb092772c5ce00a17bfcb06f6e86c5eb2018d5

Contents?: true

Size: 869 Bytes

Versions: 42

Compression:

Stored size: 869 Bytes

Contents

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

    class ShopifyApp::MissingWebhookJobError < StandardError; end

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

    private

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

    def webhook_job_klass
      webhook_job_klass_name.safe_constantize or 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

42 entries across 42 versions & 1 rubygems

Version Path
shopify_app-13.0.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-12.0.7 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-12.0.6 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-12.0.5 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-12.0.4 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-12.0.3 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-12.0.2 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-12.0.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-12.0.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.7.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.7.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.6.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.5.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.5.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.4.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.3.2 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.3.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.3.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.2.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-11.1.0 app/controllers/shopify_app/webhooks_controller.rb