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
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#jwt ⇒ Object
Returns the value of attribute jwt.
-
#load_env ⇒ Object
Returns the value of attribute load_env.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#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.
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
#client_id ⇒ Object
Returns the value of attribute client_id.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def client_secret @client_secret end |
#headers ⇒ Object
Returns the value of attribute headers.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def headers @headers end |
#jwt ⇒ Object
Returns the value of attribute jwt.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def jwt @jwt end |
#load_env ⇒ Object
Returns the value of attribute load_env.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def load_env @load_env end |
#logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def logger @logger end |
#redirect_url ⇒ Object
Returns the value of attribute redirect_url.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def redirect_url @redirect_url end |
#retry ⇒ Object
Returns the value of attribute retry.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def retry @retry end |
#retry_options ⇒ Object
Returns the value of attribute retry_options.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 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.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def token @token end |
#token_file ⇒ Object
Returns the value of attribute token_file.
12 13 14 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 12 def token_file @token_file end |
Instance Method Details
#authorize_url ⇒ Object
95 96 97 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 95 def URI.join @server_url, RingCentralSdk::REST::Client::AUTHZ_ENDPOINT end |
#default_logger ⇒ Object
29 30 31 32 33 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 29 def default_logger logger = Logger.new STDOUT logger.level = Logger::WARN logger end |
#inflate ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 20 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
76 77 78 79 80 81 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 76 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
52 53 54 55 56 57 58 59 60 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 52 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
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 62 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
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 83 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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ringcentral_sdk/rest/configuration.rb', line 35 def load_environment Dotenv.load @server_url = ENV['RINGCENTRAL_SERVER_URL'] if ENV.key? 'RINGCENTRAL_SERVER_URL' @client_id = ENV['RINGCENTRAL_CLIENT_ID'] if ENV.key? 'RINGCENTRAL_CLIENT_ID' @client_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' @jwt = ENV['RINGCENTRAL_JWT'] if ENV.key? 'RINGCENTRAL_JWT' @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 |