Class: CoreLibrary::GlobalConfiguration
- Inherits:
-
Object
- Object
- CoreLibrary::GlobalConfiguration
- Defined in:
- lib/apimatic-core/configurations/global_configuration.rb
Overview
A class to hold the global configurations for the core library. This class is initiated from the SDK.
Instance Attribute Summary collapse
-
#client_configuration ⇒ Object
readonly
Returns the value of attribute client_configuration.
Instance Method Summary collapse
-
#add_useragent_in_headers(user_agent, agent_parameters) ⇒ Object
Updates the user agent template with the provided parameters and adds user agent in the global_headers.
-
#additional_header(key, value) ⇒ GlobalConfiguration
The setter for a additional header to be attached with all requests.
-
#additional_headers(additional_headers) ⇒ GlobalConfiguration
The setter for the additional headers to be attached with all requests.
-
#auth_managers(auth_managers) ⇒ GlobalConfiguration
The setter for the auth managers.
-
#base_uri_executor(base_uri_executor) ⇒ GlobalConfiguration
The setter for the base URI extractor callable.
-
#get_additional_headers ⇒ Hash
The getter for the additional headers.
-
#get_auth_managers ⇒ Hash
The getter for the auth managers.
-
#get_base_uri_executor ⇒ Callable
The getter for the base URI extractor.
-
#get_global_errors ⇒ Hash
The getter for the global errors.
-
#get_global_headers ⇒ Hash
The getter for the global headers.
- #get_sdk_module ⇒ Object
-
#global_errors(global_errors) ⇒ GlobalConfiguration
The setter for the global errors.
-
#global_header(key, value) ⇒ GlobalConfiguration
The setter for a global header to be attached with all requests.
-
#global_headers(global_headers) ⇒ GlobalConfiguration
The setter for the global headers to be attached with all requests.
-
#initialize(client_configuration: HttpClientConfiguration.new) ⇒ GlobalConfiguration
constructor
A new instance of GlobalConfiguration.
-
#sdk_module(sdk_module) ⇒ Object
Sets the current SDK module core library is being used for.
-
#should_symbolize_hash ⇒ Boolean
The setter for the flag of wrapping the body parameters in a hash.
-
#symbolize_hash(symbolize_hash) ⇒ GlobalConfiguration
The setter for the flag of symbolizing hash while deserialization.
-
#user_agent(user_agent, agent_parameters: {}) ⇒ GlobalConfiguration
The setter for the user agent information to be attached with all requests.
Constructor Details
#initialize(client_configuration: HttpClientConfiguration.new) ⇒ GlobalConfiguration
Returns a new instance of GlobalConfiguration.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 6 def initialize(client_configuration: HttpClientConfiguration.new) @client_configuration = client_configuration @global_errors = {} @global_headers = {} @additional_headers = {} @auth_managers = {} @base_uri_executor = nil @sdk_module = nil @symbolize_hash = false end |
Instance Attribute Details
#client_configuration ⇒ Object (readonly)
Returns the value of attribute client_configuration.
4 5 6 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 4 def client_configuration @client_configuration end |
Instance Method Details
#add_useragent_in_headers(user_agent, agent_parameters) ⇒ Object
Updates the user agent template with the provided parameters and adds user agent in the global_headers.
141 142 143 144 145 146 147 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 141 def add_useragent_in_headers(user_agent, agent_parameters) if !agent_parameters.nil? && agent_parameters.any? user_agent = ApiHelper.update_user_agent_value_with_parameters(user_agent, agent_parameters).gsub(' ', ' ') end @global_headers['user-agent'] = user_agent unless user_agent.nil? end |
#additional_header(key, value) ⇒ GlobalConfiguration
The setter for a additional header to be attached with all requests.
76 77 78 79 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 76 def additional_header(key, value) @additional_headers[key] = value self end |
#additional_headers(additional_headers) ⇒ GlobalConfiguration
The setter for the additional headers to be attached with all requests.
67 68 69 70 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 67 def additional_headers(additional_headers) @additional_headers = additional_headers self end |
#auth_managers(auth_managers) ⇒ GlobalConfiguration
The setter for the auth managers.
90 91 92 93 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 90 def auth_managers(auth_managers) @auth_managers = auth_managers self end |
#base_uri_executor(base_uri_executor) ⇒ GlobalConfiguration
The setter for the base URI extractor callable.
113 114 115 116 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 113 def base_uri_executor(base_uri_executor) @base_uri_executor = base_uri_executor self end |
#get_additional_headers ⇒ Hash
The getter for the additional headers.
83 84 85 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 83 def get_additional_headers @additional_headers end |
#get_auth_managers ⇒ Hash
The getter for the auth managers.
97 98 99 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 97 def get_auth_managers @auth_managers end |
#get_base_uri_executor ⇒ Callable
The getter for the base URI extractor.
120 121 122 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 120 def get_base_uri_executor @base_uri_executor end |
#get_global_errors ⇒ Hash
The getter for the global errors.
27 28 29 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 27 def get_global_errors @global_errors end |
#get_global_headers ⇒ Hash
The getter for the global headers.
60 61 62 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 60 def get_global_headers @global_headers end |
#get_sdk_module ⇒ Object
37 38 39 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 37 def get_sdk_module @sdk_module end |
#global_errors(global_errors) ⇒ GlobalConfiguration
The setter for the global errors.
20 21 22 23 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 20 def global_errors(global_errors) @global_errors = global_errors self end |
#global_header(key, value) ⇒ GlobalConfiguration
The setter for a global header to be attached with all requests.
53 54 55 56 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 53 def global_header(key, value) @global_headers[key] = value self end |
#global_headers(global_headers) ⇒ GlobalConfiguration
The setter for the global headers to be attached with all requests.
44 45 46 47 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 44 def global_headers(global_headers) @global_headers = global_headers self end |
#sdk_module(sdk_module) ⇒ Object
Sets the current SDK module core library is being used for.
32 33 34 35 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 32 def sdk_module(sdk_module) @sdk_module = sdk_module self end |
#should_symbolize_hash ⇒ Boolean
The setter for the flag of wrapping the body parameters in a hash.
134 135 136 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 134 def should_symbolize_hash @symbolize_hash end |
#symbolize_hash(symbolize_hash) ⇒ GlobalConfiguration
The setter for the flag of symbolizing hash while deserialization.
127 128 129 130 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 127 def symbolize_hash(symbolize_hash) @symbolize_hash = symbolize_hash self end |
#user_agent(user_agent, agent_parameters: {}) ⇒ GlobalConfiguration
The setter for the user agent information to be attached with all requests.
105 106 107 108 |
# File 'lib/apimatic-core/configurations/global_configuration.rb', line 105 def user_agent(user_agent, agent_parameters: {}) add_useragent_in_headers(user_agent, agent_parameters) self end |