Class: AdwordsApi::ReportHeaderHandler
- Inherits:
-
Object
- Object
- AdwordsApi::ReportHeaderHandler
- Defined in:
- lib/adwords_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
30 31 32 33 34 |
# 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 |
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.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# 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_header = @config.read('library.include_zero_impressions_header') unless include_zero_impressions_header.nil? headers['includeZeroImpressions'] = include_zero_impressions_header.to_s end return headers end |