Class: BingAdsApi::ReportHeaderHandler
- Inherits:
-
Object
- Object
- BingAdsApi::ReportHeaderHandler
- Defined in:
- lib/bing_ads_api/report_header_handler.rb
Instance Method Summary collapse
-
#headers(url, cid) ⇒ Object
Returns the headers set for the report request.
-
#initialize(credential_handler, auth_handler, config) ⇒ ReportHeaderHandler
constructor
Initializes a header handler.
Constructor Details
#initialize(credential_handler, auth_handler, config) ⇒ ReportHeaderHandler
Initializes a header handler.
Args:
- credential_handler: a header with credential data
- auth_handler: a header with auth data
- config: API config
13 14 15 16 17 |
# File 'lib/bing_ads_api/report_header_handler.rb', line 13 def initialize(credential_handler, auth_handler, config) @credential_handler = credential_handler @auth_handler = auth_handler @config = config end |
Instance Method Details
#headers(url, cid) ⇒ Object
Returns the headers set for the report request.
Args:
- url: URL for the report requests
- cid: clientCustomerId to use
Returns:
- a Hash with HTTP headers.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bing_ads_api/report_header_handler.rb', line 28 def headers(url, cid) override = (cid.nil?) ? nil : {:client_customer_id => cid} credentials = @credential_handler.credentials(override) headers = { 'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => @auth_handler.auth_string(credentials, HTTPI::Request.new(url)), 'User-Agent' => @credential_handler.generate_user_agent(), 'clientCustomerId' => credentials[:client_customer_id].to_s, 'developerToken' => credentials[:developer_token] } money_in_micros = @config.read('library.return_money_in_micros') unless money_in_micros.nil? headers['returnMoneyInMicros'] = money_in_micros end return headers end |