Skip to Content Skip to Search
Methods
A
N
O
P
T
Included Modules

Constants

NO_PLANNING_SUPPORTED = %w[carrd duda html jekyll mailchimp notion rewardful showit squarespace stripe webflow weebly wix wordpress zapier].freeze
 
PLANNING_SUPPORTED = %w[castos circle community_box muut website_toolbox].freeze
 
PROVIDER_NAMES = (PLANNING_SUPPORTED + NO_PLANNING_SUPPORTED).freeze
 

Class Public methods

no_planning_supported()

# File app/models/db/integration.rb, line 56
def self.no_planning_supported
  NO_PLANNING_SUPPORTED
end

no_planning_supported?(integration_or_provider_name)

# File app/models/db/integration.rb, line 48
def self.no_planning_supported?(integration_or_provider_name)
  !planning_supported?(integration_or_provider_name)
end

planning_supported()

# File app/models/db/integration.rb, line 52
def self.planning_supported
  PLANNING_SUPPORTED
end

planning_supported?(integration_or_provider_name)

# File app/models/db/integration.rb, line 40
def self.planning_supported?(integration_or_provider_name)
  provider_name = integration_or_provider_name.respond_to?(:provider_name) ?
    integration_or_provider_name.provider_name :
    integration_or_provider_name

  planning_supported.include?(provider_name)
end

Instance Public methods

assigned_to_plan?(plan)

# File app/models/db/integration.rb, line 99
def assigned_to_plan?(plan)
  plan.persisted? && plan_ids.include?(plan.id)
end

on_authentication_inactive_message()

# File app/models/db/integration.rb, line 95
def on_authentication_inactive_message
  "for #{provider_name.to_s.titleize} needs to be regenerated."
end

permits_access?(member)

# File app/models/db/integration.rb, line 90
def permits_access?(member)
  return true if self.class.no_planning_supported?(self)
  member.active_plans.map(&:id).intersection(plan_ids).any?
end

podcast_ids()

# File app/models/db/integration.rb, line 103
def podcast_ids
  configuration_podcast_ids.map(&:to_i)
end

podcast_ids=(ids)

# File app/models/db/integration.rb, line 107
def podcast_ids=(ids)
  configuration["podcast_ids"] = Array(ids).map(&:to_s).reject(&:blank?)
end

provider()

# File app/models/db/integration.rb, line 64
def provider
  if provider_name
    @provider ||= begin
      "IntegrationProvider::#{provider_name.camelize}".constantize.new(self)
    rescue NameError
      errors.add(:provider, "does not exist")
      nil
    end
  end
end

provider_valid?(*args)

# File app/models/db/integration.rb, line 75
def provider_valid?(*args)
  # active support errors #valid? can take a context parameter but
  # many of the provider classes don't accept an optional parameter.
  # If a context is passed but the provider's #valid? arity is too low
  # then just return a true.
  return true unless provider.respond_to?(:valid?)
  return true if args.size > provider.method(:valid?).parameters.size

  # We want to avoid running the validations for the
  # :edit context if the integration is a new record
  return true if args.include?(:edit) && new_record?

  provider.valid?(*args)
end

to_param()

# File app/models/db/integration.rb, line 60
def to_param
  provider_name
end