Class: AdManagerApi::CredentialHandler
- Inherits:
-
AdsCommon::CredentialHandler
- Object
- AdsCommon::CredentialHandler
- AdManagerApi::CredentialHandler
- Defined in:
- lib/ad_manager_api/credential_handler.rb
Instance Method Summary collapse
-
#credentials(credentials_override = nil) ⇒ Object
Create the list of credentials to be used by the auth handler for header generation.
-
#generate_user_agent(extra_ids = [], include_utilities = true) ⇒ Object
Generates string to use as user agent in headers.
-
#identifier ⇒ Object
Returns the network code specified in the current credentials.
Instance Method Details
#credentials(credentials_override = nil) ⇒ Object
Create the list of credentials to be used by the auth handler for header generation.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ad_manager_api/credential_handler.rb', line 32 def credentials(credentials_override = nil) result = super(credentials_override) validate_headers_for_server(result) include_utils = @config.read('library.include_utilities_in_user_agent', true) result[:extra_headers] = { 'applicationName' => generate_user_agent([], include_utils), 'networkCode' => result[:network_code] } return result end |
#generate_user_agent(extra_ids = [], include_utilities = true) ⇒ Object
Generates string to use as user agent in headers.
45 46 47 48 49 50 51 52 |
# File 'lib/ad_manager_api/credential_handler.rb', line 45 def generate_user_agent(extra_ids = [], include_utilities = true) agent_app = @config.read('authentication.application_name') extra_ids << ["AdManagerApi-Ruby/%s" % AdManagerApi::ApiConfig::CLIENT_LIB_VERSION] utility_registry = AdManagerApi::Utils::UtilityRegistry.instance extra_ids += utility_registry.extract!.to_a if include_utilities super(extra_ids, agent_app) end |
#identifier ⇒ Object
Returns the network code specified in the current credentials.
55 56 57 |
# File 'lib/ad_manager_api/credential_handler.rb', line 55 def identifier() return credentials[:extra_headers]['networkCode'] end |