Sha256: 1d95cb620fd1f951e0ea59853e9a4afa4a3fff5a15c2170d15d06353a1c75f4f

Contents?: true

Size: 592 Bytes

Versions: 2

Compression:

Stored size: 592 Bytes

Contents

class <%= @job_class_name %> < ActiveJob::Base
  extend ShopifyAPI::Webhooks::Handler

  class << self
    def handle(topic:, shop:, body:)
      perform_later(topic: topic, shop_domain: shop, webhook: body)
    end
  end

  def perform(topic:, shop_domain:, webhook:)
    shop = Shop.find_by(shopify_domain: shop_domain)

    if shop.nil?
      logger.error("#{self.class} failed: cannot find shop with domain '#{shop_domain}'")

      raise ActiveRecord::RecordNotFound, "Shop Not Found"
    end

    shop.with_shopify_session do |session|
    ## webhook processing logic
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shopify_app-22.5.0 lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt
shopify_app-22.4.0 lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt