Sha256: 3368a6bab870ac83fd0c2910e5ae95c3851bfb299ebd44ca6ec41a74dd14a8f4

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

module DiscoApp
  class AppInstalledJob < DiscoApp::ShopJob

    before_enqueue { @shop.awaiting_install! }
    before_perform { @shop.installing! }
    after_perform { @shop.installed! }

    def perform(domain)

      # Install webhooks.
      (base_webhook_topics + webhook_topics).each do |topic|
        ShopifyAPI::Webhook.create(topic: topic, address: webhooks_url, format: 'json')
      end

      # Perform initial update of shop information.
      ::ShopUpdateJob.perform_now(domain)

    end

    protected

      # Return a list of additional webhook topics to listen for.
      # This method should be overridden in the application.
      def webhook_topics
        []
      end

    private

      # Return a list of webhook topics that will always be set up for the application.
      def base_webhook_topics
        [:'app/uninstalled', :'shop/update']
      end

      # Return the absolute URL to the webhooks endpoint.
      def webhooks_url
        DiscoApp::Engine.routes.url_helpers.webhooks_url
      end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
disco_app-0.3.0 app/jobs/disco_app/app_installed_job.rb
disco_app-0.4.0 app/jobs/disco_app/app_installed_job.rb
disco_app-0.4.1 app/jobs/disco_app/app_installed_job.rb
disco_app-0.4.2 app/jobs/disco_app/app_installed_job.rb
disco_app-0.4.3 app/jobs/disco_app/app_installed_job.rb
disco_app-0.4.4 app/jobs/disco_app/app_installed_job.rb
disco_app-0.5.0 app/jobs/disco_app/app_installed_job.rb
disco_app-0.5.1 app/jobs/disco_app/app_installed_job.rb
disco_app-0.5.2 app/jobs/disco_app/app_installed_job.rb
disco_app-0.5.3 app/jobs/disco_app/app_installed_job.rb
disco_app-0.5.4 app/jobs/disco_app/app_installed_job.rb
disco_app-0.5.5 app/jobs/disco_app/app_installed_job.rb
disco_app-0.5.6 app/jobs/disco_app/app_installed_job.rb