Sha256: 0ea28bf2628ab14cd8768751188e0bd283bc14bdc216bb7d5efc5e7bee305371

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module DuodealerApp
  module Utils
    def self.sanitize_account_domain(account_domain)
      name = account_domain.to_s.downcase.strip
      name += ".#{DuodealerApp.configuration.duodealer_domain}" if !name.include?("#{DuodealerApp.configuration.duodealer_domain}") && !name.include?(".")
      name.sub!(%r|https?://|, "")

      u = URI("http://#{name}")
      u.host if u.host&.match(/^[a-z0-9][a-z0-9\-]*[a-z0-9]\.#{Regexp.escape(DuodealerApp.configuration.duodealer_domain)}$/)
    rescue URI::InvalidURIError
      nil
    end

    def self.fetch_known_api_versions
      Rails.logger.info("[DuodealerAPI::ApiVersion] Fetching known Admin API Versions from Duo Dealer...")
      DuodealerAPI::ApiVersion.fetch_known_versions
      Rails.logger.info("[DuodealerAPI::ApiVersion] Known API Versions: #{DuodealerAPI::ApiVersion.versions.keys}")
      rescue ActiveResource::ConnectionError
        logger.error("[DuodealerAPI::ApiVersion] Unable to fetch api_versions from Duo Dealer")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
duodealer_app-1.0.4 lib/duodealer_app/utils.rb
duodealer_app-1.0.3 lib/duodealer_app/utils.rb
duodealer_app-1.0.2 lib/duodealer_app/utils.rb