Sha256: 33949d1001bdeabbf03cf4a263cef99ebeed3293be36ca8dc203619001e1a79c

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 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

    DiscoApp::SubscriptionService.subscribe(@shop, default_plan, plan_code, source) if default_plan.present?
  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

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.17.0 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.18.0 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.18.2 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.18.3 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.18.6 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.18.4 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.18.1 app/jobs/disco_app/concerns/app_installed_job.rb