Class: AsposeWordsCloud::Configuration

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

Overview

Class for storing API configuration info

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:



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/aspose_words_cloud/configuration.rb', line 94

def initialize
  @baseUrl = "https://api.aspose.cloud"
  @api_version = "/v4.0/"
  @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_tokenObject

Defines the access token (Bearer) used with OAuth2.



63
64
65
# File 'lib/aspose_words_cloud/configuration.rb', line 63

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)



42
43
44
# File 'lib/aspose_words_cloud/configuration.rb', line 42

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



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

def api_key_prefix
  @api_key_prefix
end

#baseUrlObject

Defines base url



34
35
36
# File 'lib/aspose_words_cloud/configuration.rb', line 34

def baseUrl
  @baseUrl
end

#client_side_validationtrue, false

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

Returns:

  • (true, false)


91
92
93
# File 'lib/aspose_words_cloud/configuration.rb', line 91

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)


73
74
75
# File 'lib/aspose_words_cloud/configuration.rb', line 73

def debugging
  @debugging
end

#logger#debug

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

Returns:

  • (#debug)


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

def logger
  @logger
end

#passwordString

Defines the password used with HTTP basic authentication.

Returns:

  • (String)


60
61
62
# File 'lib/aspose_words_cloud/configuration.rb', line 60

def password
  @password
end

#refresh_tokenObject

Defines the refresh token (Bearer) used with OAuth2.



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

def refresh_token
  @refresh_token
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)


86
87
88
# File 'lib/aspose_words_cloud/configuration.rb', line 86

def temp_folder_path
  @temp_folder_path
end

#usernameString

Defines the username used with HTTP basic authentication.

Returns:

  • (String)


55
56
57
# File 'lib/aspose_words_cloud/configuration.rb', line 55

def username
  @username
end

Class Method Details

.defaultObject

The default Configuration object.



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

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



127
128
129
130
131
132
133
# File 'lib/aspose_words_cloud/configuration.rb', line 127

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.



141
142
143
144
145
146
147
148
149
150
151
# File 'lib/aspose_words_cloud/configuration.rb', line 141

def auth_settings
  {
    'JWT' =>
      {
        type: 'oauth2',
        in: 'header',
        key: 'Authorization',
        value: "Bearer #{access_token}"
      },
  }
end

#basic_auth_tokenObject

Gets Basic Auth token string



136
137
138
# File 'lib/aspose_words_cloud/configuration.rb', line 136

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

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

yield self

Yields:

  • (_self)

Yield Parameters:



112
113
114
# File 'lib/aspose_words_cloud/configuration.rb', line 112

def configure
  yield(self) if block_given?
end

#getFullUrl(path, withoutVersion) ⇒ Object

returns base url



117
118
119
120
121
122
123
# File 'lib/aspose_words_cloud/configuration.rb', line 117

def getFullUrl(path, withoutVersion)
  if withoutVersion
    return URI.join(baseUrl, path).to_s
  end

  return  URI.join(baseUrl, "/v4.0/", path).to_s
end