class AdwordsApi::ReportHeaderHandler
Public Class Methods
new(credential_handler, auth_handler, config)
click to toggle source
Initializes a header handler.
Args:
- credential_handler: a header with credential data - auth_handler: a header with auth data - config: API config
# File lib/adwords_api/report_header_handler.rb, line 30 def initialize(credential_handler, auth_handler, config) @credential_handler = credential_handler @auth_handler = auth_handler @config = config end
Public Instance Methods
headers(url, cid)
click to toggle source
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.
# File lib/adwords_api/report_header_handler.rb, line 45 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), 'User-Agent' => @credential_handler.generate_user_agent(), 'clientCustomerId' => credentials[:client_customer_id].to_s, 'developerToken' => credentials[:developer_token] } skip_report_header = @config.read('library.skip_report_header') unless skip_report_header.nil? headers['skipReportHeader'] = skip_report_header.to_s end skip_report_summary = @config.read('library.skip_report_summary') unless skip_report_summary.nil? headers['skipReportSummary'] = skip_report_summary.to_s end skip_column_header = @config.read('library.skip_column_header') unless skip_column_header.nil? headers['skipColumnHeader'] = skip_column_header.to_s end include_zero_impressions = @config.read('library.include_zero_impressions') unless include_zero_impressions.nil? headers['includeZeroImpressions'] = include_zero_impressions.to_s end use_raw_enum_values = @config.read('library.use_raw_enum_values') unless use_raw_enum_values.nil? headers['useRawEnumValues'] = use_raw_enum_values.to_s end return headers end