Class: BingAdsApi::CredentialHandler
- Inherits:
-
AdsCommonForBingAds::CredentialHandler
- Object
- AdsCommon::CredentialHandler
- AdsCommonForBingAds::CredentialHandler
- BingAdsApi::CredentialHandler
- Defined in:
- lib/bing_ads_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.
12 13 14 15 16 17 |
# File 'lib/bing_ads_api/credential_handler.rb', line 12 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.
10 11 12 |
# File 'lib/bing_ads_api/credential_handler.rb', line 10 def partial_failure @partial_failure end |
#use_mcc ⇒ Object
Whether we’re making MCC-level requests.
6 7 8 |
# File 'lib/bing_ads_api/credential_handler.rb', line 6 def use_mcc @use_mcc end |
#validate_only ⇒ Object
Whether we’re making validate-only requests.
8 9 10 |
# File 'lib/bing_ads_api/credential_handler.rb', line 8 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.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bing_ads_api/credential_handler.rb', line 21 def credentials(credentials_override = nil) result = super(credentials_override) #puts "credentials result=\n#{result}" 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 #puts "credentials result2=\n#{result}" return result end |
#generate_user_agent(extra_ids = []) ⇒ Object
Generates string to use as user agent in headers.
41 42 43 44 45 |
# File 'lib/bing_ads_api/credential_handler.rb', line 41 def generate_user_agent(extra_ids = []) agent_app = @config.read('authentication.user_agent') extra_ids << ['AwApi-Ruby/%s' % BingAdsApi::ApiConfig::CLIENT_LIB_VERSION] super(extra_ids, agent_app) end |