Class: VericredClient::Configuration
- Inherits:
-
Object
- Object
- VericredClient::Configuration
- Defined in:
- lib/vericred_client/configuration.rb
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.
-
#base_path ⇒ Object
Defines url base path.
-
#cert_file ⇒ Object
TLS/SSL setting Client certificate file (for client certificate).
-
#debugging ⇒ true, false
Set this to enable/disable debugging.
-
#force_ending_format ⇒ Object
Returns the value of attribute force_ending_format.
-
#host ⇒ Object
Defines url host.
-
#inject_format ⇒ Object
Returns the value of attribute inject_format.
-
#key_file ⇒ Object
TLS/SSL setting Client private key file (for client certificate).
-
#logger ⇒ #debug
Defines the logger used for debugging.
-
#params_encoding ⇒ Object
Set this to customize parameters encoding of array parameter with multi collectionFormat.
-
#password ⇒ String
Defines the password used with HTTP basic authentication.
-
#scheme ⇒ Object
Defines url scheme.
-
#ssl_ca_cert ⇒ String
TLS/SSL setting Set this to customize the certificate file to verify the peer.
-
#temp_folder_path ⇒ String
Defines the temporary folder to store downloaded files (for API endpoints that have file response).
-
#timeout ⇒ Object
The time limit for HTTP request in seconds.
-
#username ⇒ String
Defines the username used with HTTP basic authentication.
-
#verify_ssl ⇒ true, false
TLS/SSL setting Set this to false to skip verifying SSL certificate when calling API from https server.
-
#verify_ssl_host ⇒ true, false
TLS/SSL setting Set this to false to skip verifying SSL host name Default to true.
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
-
#basic_auth_token ⇒ Object
Gets Basic Auth token string.
- #configure {|_self| ... } ⇒ Object
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 |
# File 'lib/vericred_client/configuration.rb', line 1121 def initialize @scheme = 'https' @host = 'api.vericred.com' @base_path = '/' @api_key = {} @api_key_prefix = {} @timeout = 0 @verify_ssl = true @verify_ssl_host = true @params_encoding = nil @cert_file = nil @key_file = nil @debugging = false @inject_format = false @force_ending_format = 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.
1049 1050 1051 |
# File 'lib/vericred_client/configuration.rb', line 1049 def access_token @access_token end |
#api_key ⇒ Hash
Defines API keys used with API Key authentications.
1028 1029 1030 |
# File 'lib/vericred_client/configuration.rb', line 1028 def api_key @api_key end |
#api_key_prefix ⇒ Hash
Defines API key prefixes used with API Key authentications.
1036 1037 1038 |
# File 'lib/vericred_client/configuration.rb', line 1036 def api_key_prefix @api_key_prefix end |
#base_path ⇒ Object
Defines url base path
1020 1021 1022 |
# File 'lib/vericred_client/configuration.rb', line 1020 def base_path @base_path end |
#cert_file ⇒ Object
TLS/SSL setting Client certificate file (for client certificate)
1104 1105 1106 |
# File 'lib/vericred_client/configuration.rb', line 1104 def cert_file @cert_file 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.
1056 1057 1058 |
# File 'lib/vericred_client/configuration.rb', line 1056 def debugging @debugging end |
#force_ending_format ⇒ Object
Returns the value of attribute force_ending_format.
1119 1120 1121 |
# File 'lib/vericred_client/configuration.rb', line 1119 def force_ending_format @force_ending_format end |
#host ⇒ Object
Defines url host
1017 1018 1019 |
# File 'lib/vericred_client/configuration.rb', line 1017 def host @host end |
#inject_format ⇒ Object
Returns the value of attribute inject_format.
1117 1118 1119 |
# File 'lib/vericred_client/configuration.rb', line 1117 def inject_format @inject_format end |
#key_file ⇒ Object
TLS/SSL setting Client private key file (for client certificate)
1108 1109 1110 |
# File 'lib/vericred_client/configuration.rb', line 1108 def key_file @key_file end |
#logger ⇒ #debug
Defines the logger used for debugging. Default to ‘Rails.logger` (when in Rails) or logging to STDOUT.
1062 1063 1064 |
# File 'lib/vericred_client/configuration.rb', line 1062 def logger @logger end |
#params_encoding ⇒ Object
Set this to customize parameters encoding of array parameter with multi collectionFormat. Default to nil.
github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
1115 1116 1117 |
# File 'lib/vericred_client/configuration.rb', line 1115 def params_encoding @params_encoding end |
#password ⇒ String
Defines the password used with HTTP basic authentication.
1046 1047 1048 |
# File 'lib/vericred_client/configuration.rb', line 1046 def password @password end |
#scheme ⇒ Object
Defines url scheme
1014 1015 1016 |
# File 'lib/vericred_client/configuration.rb', line 1014 def scheme @scheme end |
#ssl_ca_cert ⇒ String
TLS/SSL setting Set this to customize the certificate file to verify the peer.
github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
1100 1101 1102 |
# File 'lib/vericred_client/configuration.rb', line 1100 def ssl_ca_cert @ssl_ca_cert end |
#temp_folder_path ⇒ String
Defines the temporary folder to store downloaded files (for API endpoints that have file response). Default to use ‘Tempfile`.
1069 1070 1071 |
# File 'lib/vericred_client/configuration.rb', line 1069 def temp_folder_path @temp_folder_path end |
#timeout ⇒ Object
The time limit for HTTP request in seconds. Default to 0 (never times out).
1073 1074 1075 |
# File 'lib/vericred_client/configuration.rb', line 1073 def timeout @timeout end |
#username ⇒ String
Defines the username used with HTTP basic authentication.
1041 1042 1043 |
# File 'lib/vericred_client/configuration.rb', line 1041 def username @username end |
#verify_ssl ⇒ true, false
Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
TLS/SSL setting Set this to false to skip verifying SSL certificate when calling API from https server. Default to true.
1082 1083 1084 |
# File 'lib/vericred_client/configuration.rb', line 1082 def verify_ssl @verify_ssl end |
#verify_ssl_host ⇒ true, false
Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
TLS/SSL setting Set this to false to skip verifying SSL host name Default to true.
1091 1092 1093 |
# File 'lib/vericred_client/configuration.rb', line 1091 def verify_ssl_host @verify_ssl_host end |
Class Method Details
.default ⇒ Object
The default Configuration object.
1142 1143 1144 |
# File 'lib/vericred_client/configuration.rb', line 1142 def self.default @@default ||= Configuration.new end |
Instance Method Details
#api_key_with_prefix(param_name) ⇒ Object
Gets API key (with prefix if set).
1173 1174 1175 1176 1177 1178 1179 |
# File 'lib/vericred_client/configuration.rb', line 1173 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.
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 |
# File 'lib/vericred_client/configuration.rb', line 1187 def auth_settings { 'Vericred-Api-Key' => { type: 'api_key', in: 'header', key: 'Vericred-Api-Key', value: api_key_with_prefix('Vericred-Api-Key') }, } end |
#base_url ⇒ Object
1166 1167 1168 1169 |
# File 'lib/vericred_client/configuration.rb', line 1166 def base_url url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') URI.encode(url) end |
#basic_auth_token ⇒ Object
Gets Basic Auth token string
1182 1183 1184 |
# File 'lib/vericred_client/configuration.rb', line 1182 def basic_auth_token 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n") end |
#configure {|_self| ... } ⇒ Object
1146 1147 1148 |
# File 'lib/vericred_client/configuration.rb', line 1146 def configure yield(self) if block_given? end |