Class: AsposeWordsCloud::Configuration
- Inherits:
-
Object
- Object
- AsposeWordsCloud::Configuration
- Defined in:
- lib/aspose_words_cloud/configuration.rb
Overview
Class for storing API configuration info
Constant Summary collapse
- V4_API_VERSION =
Defines v4 api version
'/v4.0'.freeze
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Defines the access token (Bearer) used with OAuth2.
-
#api_key ⇒ Hash
Defines API keys used with API Key authentications.
-
#api_key_prefix ⇒ Hash
Defines API key prefixes used with API Key authentications.
-
#api_version ⇒ Object
Defines url api version.
-
#client_side_validation ⇒ true, false
Set this to false to skip client side validation in the operation.
-
#debugging ⇒ true, false
Set this to enable/disable debugging.
-
#host ⇒ Object
Defines url host.
-
#logger ⇒ #debug
Defines the logger used for debugging.
-
#password ⇒ String
Defines the password used with HTTP basic authentication.
-
#refresh_token ⇒ Object
Defines the refresh token (Bearer) used with OAuth2.
-
#scheme ⇒ Object
Defines url scheme.
-
#temp_folder_path ⇒ String
Defines the temporary folder to store downloaded files (for API endpoints that have file response).
-
#username ⇒ String
Defines the username used with HTTP basic authentication.
Class Method Summary collapse
-
.default ⇒ Object
The default Configuration object.
Instance Method Summary collapse
-
#api_key_with_prefix(param_name) ⇒ Object
Gets API key (with prefix if set).
-
#auth_settings ⇒ Object
Returns Auth Settings hash for api client.
-
#base_url ⇒ Object
returns base url.
-
#basic_auth_token ⇒ Object
Gets Basic Auth token string.
-
#configure {|_self| ... } ⇒ Object
yield self.
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/aspose_words_cloud/configuration.rb', line 104 def initialize @scheme = 'https' @host = "api.aspose.cloud" @api_version = V4_API_VERSION @api_key = {} @api_key_prefix = {} @client_side_validation = true @debugging = false @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) yield(self) if block_given? end |
Instance Attribute Details
#access_token ⇒ Object
Defines the access token (Bearer) used with OAuth2.
73 74 75 |
# File 'lib/aspose_words_cloud/configuration.rb', line 73 def access_token @access_token end |
#api_key ⇒ Hash
Defines API keys used with API Key authentications.
52 53 54 |
# File 'lib/aspose_words_cloud/configuration.rb', line 52 def api_key @api_key end |
#api_key_prefix ⇒ Hash
Defines API key prefixes used with API Key authentications.
60 61 62 |
# File 'lib/aspose_words_cloud/configuration.rb', line 60 def api_key_prefix @api_key_prefix end |
#api_version ⇒ Object
Defines url api version
44 45 46 |
# File 'lib/aspose_words_cloud/configuration.rb', line 44 def api_version @api_version end |
#client_side_validation ⇒ true, false
Set this to false to skip client side validation in the operation. Default to true.
101 102 103 |
# File 'lib/aspose_words_cloud/configuration.rb', line 101 def client_side_validation @client_side_validation end |
#debugging ⇒ true, false
Set this to enable/disable debugging. When enabled (set to true), HTTP request/response details will be logged with ‘logger.debug` (see the `logger` attribute). Default to false.
83 84 85 |
# File 'lib/aspose_words_cloud/configuration.rb', line 83 def debugging @debugging end |
#host ⇒ Object
Defines url host
41 42 43 |
# File 'lib/aspose_words_cloud/configuration.rb', line 41 def host @host end |
#logger ⇒ #debug
Defines the logger used for debugging. Default to ‘Rails.logger` (when in Rails) or logging to STDOUT.
89 90 91 |
# File 'lib/aspose_words_cloud/configuration.rb', line 89 def logger @logger end |
#password ⇒ String
Defines the password used with HTTP basic authentication.
70 71 72 |
# File 'lib/aspose_words_cloud/configuration.rb', line 70 def password @password end |
#refresh_token ⇒ Object
Defines the refresh token (Bearer) used with OAuth2.
76 77 78 |
# File 'lib/aspose_words_cloud/configuration.rb', line 76 def refresh_token @refresh_token end |
#scheme ⇒ Object
Defines url scheme
38 39 40 |
# File 'lib/aspose_words_cloud/configuration.rb', line 38 def scheme @scheme end |
#temp_folder_path ⇒ String
Defines the temporary folder to store downloaded files (for API endpoints that have file response). Default to use ‘Tempfile`.
96 97 98 |
# File 'lib/aspose_words_cloud/configuration.rb', line 96 def temp_folder_path @temp_folder_path end |
#username ⇒ String
Defines the username used with HTTP basic authentication.
65 66 67 |
# File 'lib/aspose_words_cloud/configuration.rb', line 65 def username @username end |
Class Method Details
.default ⇒ Object
The default Configuration object.
118 119 120 |
# File 'lib/aspose_words_cloud/configuration.rb', line 118 def self.default @@default ||= Configuration.new end |
Instance Method Details
#api_key_with_prefix(param_name) ⇒ Object
Gets API key (with prefix if set).
147 148 149 150 151 152 153 |
# File 'lib/aspose_words_cloud/configuration.rb', line 147 def api_key_with_prefix(param_name) if @api_key_prefix[param_name] "#{@api_key_prefix[param_name]} #{@api_key[param_name]}" else @api_key[param_name] end end |
#auth_settings ⇒ Object
Returns Auth Settings hash for api client.
161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/aspose_words_cloud/configuration.rb', line 161 def auth_settings { 'JWT' => { type: 'oauth2', in: 'header', key: 'Authorization', value: "Bearer #{access_token}" }, } end |
#base_url ⇒ Object
returns base url
140 141 142 143 |
# File 'lib/aspose_words_cloud/configuration.rb', line 140 def base_url url = "#{scheme}://#{[host, @api_version].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') URI.encode(url) end |
#basic_auth_token ⇒ Object
Gets Basic Auth token string
156 157 158 |
# File 'lib/aspose_words_cloud/configuration.rb', line 156 def basic_auth_token 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n") end |
#configure {|_self| ... } ⇒ Object
yield self
123 124 125 |
# File 'lib/aspose_words_cloud/configuration.rb', line 123 def configure yield(self) if block_given? end |