Class: AdwordsApi::CredentialHandler
- Inherits:
-
AdsCommon::CredentialHandler
- Object
- AdsCommon::CredentialHandler
- AdwordsApi::CredentialHandler
- Defined in:
- lib/adwords_api/credential_handler.rb
Instance Attribute Summary collapse
-
#partial_failure ⇒ Object
Whether we’re making partial failure requests.
-
#use_mcc ⇒ Object
Whether we’re making MCC-level requests.
-
#validate_only ⇒ Object
Whether we’re making validate-only requests.
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 = []) ⇒ Object
Generates string to use as user agent in headers.
-
#initialize(config) ⇒ CredentialHandler
constructor
A new instance of CredentialHandler.
Constructor Details
#initialize(config) ⇒ CredentialHandler
Returns a new instance of CredentialHandler.
34 35 36 37 38 39 |
# File 'lib/adwords_api/credential_handler.rb', line 34 def initialize(config) super(config) @use_mcc = false @validate_only = false @partial_failure = false end |
Instance Attribute Details
#partial_failure ⇒ Object
Whether we’re making partial failure requests.
32 33 34 |
# File 'lib/adwords_api/credential_handler.rb', line 32 def partial_failure @partial_failure end |
#use_mcc ⇒ Object
Whether we’re making MCC-level requests.
28 29 30 |
# File 'lib/adwords_api/credential_handler.rb', line 28 def use_mcc @use_mcc end |
#validate_only ⇒ Object
Whether we’re making validate-only requests.
30 31 32 |
# File 'lib/adwords_api/credential_handler.rb', line 30 def validate_only @validate_only end |
Instance Method Details
#credentials(credentials_override = nil) ⇒ Object
Create the list of credentials to be used by the auth handler for header generation.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/adwords_api/credential_handler.rb', line 43 def credentials(credentials_override = nil) result = super(credentials_override) validate_headers_for_server(result) extra_headers = { 'userAgent' => generate_user_agent(), 'developerToken' => result[:developer_token] } if !@use_mcc and result[:client_customer_id] extra_headers['clientCustomerId'] = result[:client_customer_id] end extra_headers['validateOnly'] = 'true' if @validate_only extra_headers['partialFailure'] = 'true' if @partial_failure result[:extra_headers] = extra_headers return result end |
#generate_user_agent(extra_ids = []) ⇒ Object
Generates string to use as user agent in headers.
61 62 63 64 65 |
# File 'lib/adwords_api/credential_handler.rb', line 61 def generate_user_agent(extra_ids = []) agent_app = @config.read('authentication.user_agent') extra_ids << ['AwApi-Ruby/%s' % AdwordsApi::ApiConfig::CLIENT_LIB_VERSION] super(extra_ids, agent_app) end |