Module: DuodealerApp::Utils

Defined in:
lib/duodealer_app/utils.rb

Class Method Summary collapse

Class Method Details

.fetch_known_api_versionsObject



16
17
18
19
20
21
22
# File 'lib/duodealer_app/utils.rb', line 16

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

.sanitize_account_domain(account_domain) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/duodealer_app/utils.rb', line 5

def self.()
  name = .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