Class: JustimmoClient::Config Private

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Configurable
Defined in:
lib/justimmo_client/core/config.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Configuration options storage

Constant Summary collapse

SUPPORTED_API_VERSIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[1].freeze
REQUIRED =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[username password].freeze

Class Method Summary collapse

Class Method Details

.configureObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
# File 'lib/justimmo_client/core/config.rb', line 30

def configure
  super
  self.credentials = Base64.urlsafe_encode64("#{username}:#{password}")
  validate_api_version
end

.credentialsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
49
# File 'lib/justimmo_client/core/config.rb', line 46

def credentials
  validate_credentials
  @_config[:credentials]
end

.urlObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
54
# File 'lib/justimmo_client/core/config.rb', line 51

def url
  return "#{base_url}/v#{api_ver}" if self.base_url.start_with?("http")
  "#{secure ? 'https' : 'http'}://#{base_url}/v#{api_ver}"
end

.validate_api_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
44
# File 'lib/justimmo_client/core/config.rb', line 41

def validate_api_version
  supported_ver = SUPPORTED_API_VERSIONS.include?(api_ver)
  raise JustimmoClient::UnsupportedAPIVersion, api_ver unless supported_ver
end

.validate_credentialsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
39
# File 'lib/justimmo_client/core/config.rb', line 36

def validate_credentials
  missing = REQUIRED.select { |r| @_config[r].nil? }
  raise JustimmoClient::MissingConfiguration, missing unless missing.empty?
end