Sha256: 860c1d1fdbab00e4e21155a65fcc721544903d368b72c004c969727078ca96d7

Contents?: true

Size: 631 Bytes

Versions: 7

Compression:

Stored size: 631 Bytes

Contents

module ShopifyApp
  class WebhooksController < ApplicationController
    include ShopifyApp::WebhookVerification

    class ShopifyApp::MissingWebhookJobError < StandardError; end

    def receive
      job_args = {shop_domain: shop_domain, webhook: webhook_params}
      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_type.classify}Job".safe_constantize or raise ShopifyApp::MissingWebhookJobError
    end

    def webhook_type
      params[:type]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shopify_app-7.0.7 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-7.0.6 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-7.0.5 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-7.0.4 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-7.0.2 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-7.0.1 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-7.0.0 app/controllers/shopify_app/webhooks_controller.rb