class RingCentralSdk::REST::Configuration

Configuration class populated by Client constructor block

Attributes

app_key[RW]
app_secret[RW]
extension[RW]
headers[RW]
load_env[RW]
logger[RW]
password[RW]
redirect_url[RW]
retry[RW]
retry_options[RW]
server_url[RW]
token[RW]
token_file[RW]
username[RW]

Public Instance Methods

authorize_url() click to toggle source
# File lib/ringcentral_sdk/rest/configuration.rb, line 103
def authorize_url
  URI.join(@server_url, RingCentralSdk::REST::Client::AUTHZ_ENDPOINT)
end
default_logger() click to toggle source
# File lib/ringcentral_sdk/rest/configuration.rb, line 38
def default_logger
  logger = Logger.new STDOUT
  logger.level = Logger::WARN
  logger
end
inflate() click to toggle source
# File lib/ringcentral_sdk/rest/configuration.rb, line 29
def inflate
  @logger = default_logger if !defined?(@logger) || @logger.nil?
  load_environment if load_env
  inflate_headers
  inflate_retry
  inflate_retry_options
  inflate_token
end
inflate_headers() click to toggle source
# File lib/ringcentral_sdk/rest/configuration.rb, line 84
def inflate_headers
  @headers = {} unless defined? @headers
  if !@headers.nil? && @headers.is_a?(String) && @headers =~ /^\s*{/
    @headers = MultiJson.decode @headers, symbolize_keys: true
  end
end
inflate_retry() click to toggle source
# File lib/ringcentral_sdk/rest/configuration.rb, line 60
def inflate_retry
  if !defined?(@retry) || @retry.nil?
    @retry = false
  elsif @retry.is_a? String
    @retry = @retry.to_s.strip.downcase == 'true' ? true : false
  elsif ![true, false].include? @retry
    @retry = @retry ? true : false
  end
end
inflate_retry_options() click to toggle source
# File lib/ringcentral_sdk/rest/configuration.rb, line 70
def inflate_retry_options
  if @retry == false
    @retry_options = {}
    return
  end
  if !@retry_options.nil? && @retry_options.to_s =~ /^\s*{/
    @retry_options = MultiJson.decode @retry_options.to_s, symbolize_keys: true
  else
    @retry_options = {}
  end
  @retry_options[:error_codes] = [429, 503, 504] unless @retry_options.key? :error_codes
  @retry_options[:logger] = @logger
end
inflate_token() click to toggle source
# File lib/ringcentral_sdk/rest/configuration.rb, line 91
def inflate_token
  @token = nil unless defined? @token

  if (@token.nil? || @token.empty?) && !token_file.nil? && !@token_file.empty?
    @token = IO.read @token_file if File.exist? @token_file
  end

  if !defined?(@token) && !@token.nil? && @token.is_a?(String) && @token =~ /^\s*{/
    @token = MultiJson.decode @token
  end
end
load_environment() click to toggle source
# File lib/ringcentral_sdk/rest/configuration.rb, line 44
def load_environment
  Dotenv.load
  @server_url = ENV['RC_SERVER_URL'] if ENV.key? 'RC_SERVER_URL'
  @app_key = ENV['RC_APP_KEY'] if ENV.key? 'RC_APP_KEY'
  @app_secret = ENV['RC_APP_SECRET'] if ENV.key? 'RC_APP_SECRET'
  @redirect_url = ENV['RC_APP_REDIRECT_URL'] if ENV.key? 'RC_APP_REDIRECT_URL'
  @username = ENV['RC_USER_USERNAME'] if ENV.key? 'RC_USER_USERNAME'
  @extension = ENV['RC_USER_EXTENSION'] if ENV.key? 'RC_USER_EXTENSION'
  @password = ENV['RC_USER_PASSWORD'] if ENV.key? 'RC_USER_PASSWORD'
  @token = ENV['RC_TOKEN'] if ENV.key? 'RC_TOKEN'
  @token_file = ENV['RC_TOKEN_FILE'] if ENV.key? 'RC_TOKEN_FILE'
  @retry = ENV['RC_RETRY'] if ENV.key? 'RC_RETRY'
  @retry_options = ENV['RC_RETRY_OPTIONS'] if ENV.key? 'RC_RETRY_OPTIONS'
  @headers = ENV['RC_HEADERS'] if ENV.key? 'RC_HEADERS'
end