Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

473 B
Raw Blame
class Shopify::FeatureGate
  ACCOUNT_FEATURE = 'shopify_integration'.freeze
  GLOBAL_CONFIG = 'ENABLE_SHOPIFY_INTEGRATION'.freeze

  def self.enabled?(account: nil)
    return false unless globally_enabled?

    account.nil? || account.feature_enabled?(ACCOUNT_FEATURE)
  end

  def self.globally_enabled?
    configured_value = ENV.fetch(GLOBAL_CONFIG) { GlobalConfig.get(GLOBAL_CONFIG)[GLOBAL_CONFIG] }
    ActiveModel::Type::Boolean.new.cast(configured_value)
  end
end