Class: AsposeCadCloud::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/aspose_cad_cloud/configuration.rb

Overview

Class for storing API configuration info

Constant Summary collapse

V1_API_VERSION =

Defines v1 api version

'/v1.0'.freeze
V2_API_VERSION =

Defines v2 api version

'/v2.0'.freeze
V3_API_VERSION =

Defines v3 api version

'/v3.0'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/aspose_cad_cloud/configuration.rb', line 110

def initialize
  @scheme = 'https'
  @host = "api.aspose.cloud"
  @api_version = V3_API_VERSION
  @api_key = {}
  @api_key_prefix = {}
  @client_side_validation = true
  @debugging = false
  @logger = Logger.new(STDOUT)

  yield(self) if block_given?
end

Instance Attribute Details

#access_tokenObject

Defines the access token (Bearer) used with OAuth2.



79
80
81
# File 'lib/aspose_cad_cloud/configuration.rb', line 79

def access_token
  @access_token
end

#api_keyHash

Defines API keys used with API Key authentications.

Examples:

parameter name is “api_key”, API key is “xxx” (e.g. “api_key=xxx” in query string)

config.api_key['api_key'] = 'xxx'

Returns:

  • (Hash)

    key: parameter name, value: parameter value (API key)



58
59
60
# File 'lib/aspose_cad_cloud/configuration.rb', line 58

def api_key
  @api_key
end

#api_key_prefixHash

Defines API key prefixes used with API Key authentications.

Examples:

parameter name is “Authorization”, API key prefix is “Token” (e.g. “Authorization: Token xxx” in headers)

config.api_key_prefix['api_key'] = 'Token'

Returns:

  • (Hash)

    key: parameter name, value: API key prefix



66
67
68
# File 'lib/aspose_cad_cloud/configuration.rb', line 66

def api_key_prefix
  @api_key_prefix
end

#api_versionObject

Defines url api version



50
51
52
# File 'lib/aspose_cad_cloud/configuration.rb', line 50

def api_version
  @api_version
end

#client_side_validationtrue, false

Set this to false to skip client side validation in the operation. Default to true.

Returns:

  • (true, false)


107
108
109
# File 'lib/aspose_cad_cloud/configuration.rb', line 107

def client_side_validation
  @client_side_validation
end

#debuggingtrue, 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.

Returns:

  • (true, false)


89
90
91
# File 'lib/aspose_cad_cloud/configuration.rb', line 89

def debugging
  @debugging
end

#hostObject

Defines url host



47
48
49
# File 'lib/aspose_cad_cloud/configuration.rb', line 47

def host
  @host
end

#logger#debug

Defines the logger used for debugging. Default to ‘Rails.logger` (when in Rails) or logging to STDOUT.

Returns:

  • (#debug)


95
96
97
# File 'lib/aspose_cad_cloud/configuration.rb', line 95

def logger
  @logger
end

#passwordString

Defines the password used with HTTP basic authentication.

Returns:

  • (String)


76
77
78
# File 'lib/aspose_cad_cloud/configuration.rb', line 76

def password
  @password
end

#refresh_tokenObject

Defines the refresh token (Bearer) used with OAuth2.



82
83
84
# File 'lib/aspose_cad_cloud/configuration.rb', line 82

def refresh_token
  @refresh_token
end

#schemeObject

Defines url scheme



44
45
46
# File 'lib/aspose_cad_cloud/configuration.rb', line 44

def scheme
  @scheme
end

#temp_folder_pathString

Defines the temporary folder to store downloaded files (for API endpoints that have file response). Default to use ‘Tempfile`.

Returns:

  • (String)


102
103
104
# File 'lib/aspose_cad_cloud/configuration.rb', line 102

def temp_folder_path
  @temp_folder_path
end

#usernameString

Defines the username used with HTTP basic authentication.

Returns:

  • (String)


71
72
73
# File 'lib/aspose_cad_cloud/configuration.rb', line 71

def username
  @username
end

Class Method Details

.defaultObject

The default Configuration object.



124
125
126
# File 'lib/aspose_cad_cloud/configuration.rb', line 124

def self.default
  @@default ||= Configuration.new
end

Instance Method Details

#api_key_with_prefix(param_name) ⇒ Object

Gets API key (with prefix if set).

Parameters:

  • param_name (String)

    the parameter name of API key auth



160
161
162
163
164
165
166
# File 'lib/aspose_cad_cloud/configuration.rb', line 160

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_settingsObject

Returns Auth Settings hash for api client.



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/aspose_cad_cloud/configuration.rb', line 174

def auth_settings
  {
    'ApiKey' =>
      {
        type: 'api_key',
        in: 'header',
        key: 'Authorization',
        value: api_key_with_prefix('Authorization')
      },
    'Bearer' =>
      {
        type: 'oauth2',
        in: 'header',
        key: 'Authorization',
        value: "Bearer #{access_token}"
      },
  }
end

#base_urlObject

returns base url



153
154
155
156
# File 'lib/aspose_cad_cloud/configuration.rb', line 153

def base_url
  url = "#{scheme}://#{[host, api_version].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
  return URI::Parser.new.escape url
end

#basic_auth_tokenObject

Gets Basic Auth token string



169
170
171
# File 'lib/aspose_cad_cloud/configuration.rb', line 169

def basic_auth_token
  'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
end

#configure {|_self| ... } ⇒ Object

yield self

Yields:

  • (_self)

Yield Parameters:



129
130
131
# File 'lib/aspose_cad_cloud/configuration.rb', line 129

def configure
  yield(self) if block_given?
end