Sha256: 5c83ac5fa5559c69b25dbfa7993fe2e85aa873e6b8d52b47119f4ba0d5eb765e

Contents?: true

Size: 664 Bytes

Versions: 2

Compression:

Stored size: 664 Bytes

Contents

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

    class ShopifyApp::MissingWebhookJobError < StandardError; end

    def receive
      params.try(: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_type.classify}Job".safe_constantize or raise ShopifyApp::MissingWebhookJobError
    end

    def webhook_type
      params[:type]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shopify_app-8.1.0 app/controllers/shopify_app/webhooks_controller.rb
shopify_app-8.0.0 app/controllers/shopify_app/webhooks_controller.rb