Class: RingCentralSdk::REST::Configuration
- Inherits:
-
Object
- Object
- RingCentralSdk::REST::Configuration
- Defined in:
- lib/ringcentral_sdk/rest/configuration.rb
Overview
Configuration class populated by Client constructor block
Instance Attribute Summary collapse
-
#app_key ⇒ Object
Returns the value of attribute app_key.
-
#app_secret ⇒ Object
Returns the value of attribute app_secret.
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#load_env ⇒ Object
Returns the value of attribute load_env.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#password ⇒ Object
Returns the value of attribute password.
-
#redirect_url ⇒ Object
Returns the value of attribute redirect_url.
-
#retry ⇒ Object
Returns the value of attribute retry.
-
#retry_options ⇒ Object
Returns the value of attribute retry_options.
-
#server_url ⇒ Object
Returns the value of attribute server_url.
-
#token ⇒ Object
Returns the value of attribute token.
-
#token_file ⇒ Object
Returns the value of attribute token_file.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #authorize_url ⇒ Object
- #default_logger ⇒ Object
- #inflate ⇒ Object
- #inflate_headers ⇒ Object
- #inflate_retry ⇒ Object
- #inflate_retry_options ⇒ Object
- #inflate_token ⇒ Object
- #load_environment ⇒ Object
Instance Attribute Details
#app_key ⇒ Object
Returns the value of attribute app_key.
13 14 15 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 13 def app_key @app_key end |
#app_secret ⇒ Object
Returns the value of attribute app_secret.
14 15 16 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 14 def app_secret @app_secret end |
#extension ⇒ Object
Returns the value of attribute extension.
18 19 20 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 18 def extension @extension end |
#headers ⇒ Object
Returns the value of attribute headers.
24 25 26 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 24 def headers @headers end |
#load_env ⇒ Object
Returns the value of attribute load_env.
23 24 25 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 23 def load_env @load_env end |
#logger ⇒ Object
Returns the value of attribute logger.
27 28 29 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 27 def logger @logger end |
#password ⇒ Object
Returns the value of attribute password.
19 20 21 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 19 def password @password end |
#redirect_url ⇒ Object
Returns the value of attribute redirect_url.
15 16 17 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 15 def redirect_url @redirect_url end |
#retry ⇒ Object
Returns the value of attribute retry.
25 26 27 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 25 def retry @retry end |
#retry_options ⇒ Object
Returns the value of attribute retry_options.
26 27 28 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 26 def @retry_options end |
#server_url ⇒ Object
Returns the value of attribute server_url.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def server_url @server_url end |
#token ⇒ Object
Returns the value of attribute token.
20 21 22 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 20 def token @token end |
#token_file ⇒ Object
Returns the value of attribute token_file.
21 22 23 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 21 def token_file @token_file end |
#username ⇒ Object
Returns the value of attribute username.
17 18 19 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 17 def username @username end |
Instance Method Details
#authorize_url ⇒ Object
103 104 105 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 103 def URI.join @server_url, RingCentralSdk::REST::Client::AUTHZ_ENDPOINT end |
#default_logger ⇒ Object
38 39 40 41 42 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 38 def default_logger logger = Logger.new STDOUT logger.level = Logger::WARN logger end |
#inflate ⇒ Object
29 30 31 32 33 34 35 36 |
# 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_token end |
#inflate_headers ⇒ Object
84 85 86 87 88 89 |
# 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 ⇒ Object
60 61 62 63 64 65 66 67 68 |
# 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 ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 70 def 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 ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 |
# 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 ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 44 def load_environment Dotenv.load @server_url = ENV['RINGCENTRAL_SERVER_URL'] if ENV.key? 'RINGCENTRAL_SERVER_URL' @app_key = ENV['RINGCENTRAL_CLIENT_ID'] if ENV.key? 'RINGCENTRAL_CLIENT_ID' @app_secret = ENV['RINGCENTRAL_CLIENT_SECRET'] if ENV.key? 'RINGCENTRAL_CLIENT_SECRET' @redirect_url = ENV['RINGCENTRAL_REDIRECT_URL'] if ENV.key? 'RINGCENTRAL_REDIRECT_URL' @username = ENV['RINGCENTRAL_USERNAME'] if ENV.key? 'RINGCENTRAL_USERNAME' @extension = ENV['RINGCENTRAL_EXTENSION'] if ENV.key? 'RINGCENTRAL_EXTENSION' @password = ENV['RINGCENTRAL_PASSWORD'] if ENV.key? 'RINGCENTRAL_PASSWORD' @token = ENV['RINGCENTRAL_TOKEN'] if ENV.key? 'RINGCENTRAL_TOKEN' @token_file = ENV['RINGCENTRAL_TOKEN_FILE'] if ENV.key? 'RINGCENTRAL_TOKEN_FILE' @retry = ENV['RINGCENTRAL_RETRY'] if ENV.key? 'RINGCENTRAL_RETRY' @retry_options = ENV['RINGCENTRAL_RETRY_OPTIONS'] if ENV.key? 'RINGCENTRAL_RETRY_OPTIONS' @headers = ENV['RINGCENTRAL_HEADERS'] if ENV.key? 'RINGCENTRAL_HEADERS' end |