Sha256: f1e9baebff0e51a5d072b416392f474528acc5609bba02d2a92695a0b70e1379

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 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(shopify_domain, plan_code = nil, source = nil)
    DiscoApp::SynchroniseWebhooksJob.perform_now(shopify_domain)
    DiscoApp::SynchroniseCarrierServiceJob.perform_now(shopify_domain)
    DiscoApp::ShopUpdateJob.perform_now(shopify_domain)

    @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

5 entries across 5 versions & 1 rubygems

Version Path
disco_app-0.8.9 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.9.0 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.9.1 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.9.2 app/jobs/disco_app/concerns/app_installed_job.rb
disco_app-0.9.3 app/jobs/disco_app/concerns/app_installed_job.rb