Sha256: 4f7b26bd19802488c5c2a5c7c1d95a90feaf66abb8e74a54b93c4f0deb02d003

Contents?: true

Size: 1.17 KB

Versions: 17

Compression:

Stored size: 1.17 KB

Contents

module DiscoApp::Concerns::AppInstalledJob
  extend ActiveSupport::Concern

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

  # Perform application installation.
  #
  # - Synchronise webhooks.
  # - Synchronise carrier service, if required.
  # - Perform initial update of shop information.
  # - Subscribe to default plan, if any exists.
  #
  def perform(_shop, plan_code = nil, source = nil)
    DiscoApp::SynchroniseWebhooksJob.perform_now(@shop)
    DiscoApp::SynchroniseCarrierServiceJob.perform_now(@shop)
    DiscoApp::ShopUpdateJob.perform_now(@shop)

    @shop.reload

    if default_plan.present?
      DiscoApp::SubscriptionService.subscribe(@shop, default_plan, plan_code, source)
    end
  end

  # Provide an overridable hook for applications to examine the @shop object
  # and return the default plan, if any, the shop should be subscribed to. If
  # nil is returned, no automatic subscription will take place and the store
  # owner will be forced to choose a plan after installation.
  #
  # If implementing this method, it should be memoized.
  def default_plan
    nil
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.13.3 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.13.4 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.13.5 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.13.6 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.13.7 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.13.8 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.14.1 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.14.2 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.15.0 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.16.0 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.14.4 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.14.3 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.16.1 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.15.2 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.14.0 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.13.6.pre.puma.pre.3 app/jobs/disco_app/concerns/app_installed_job.rb