Skip to content

All but the final dimension are ignored in Adsense generate_report #292

Closed
@barancw

Description

When you pass multiple dimensions to an adsense report, all but the last one are ignored.

See test below:

require 'spec_helper'
require 'google/apis/adsense_v1_4'
require 'googleauth'

Adsense = Google::Apis::AdsenseV1_4

RSpec.describe Google::Apis::AdsenseV1_4, :if => run_integration_tests? do

  before(:context) do
    WebMock.allow_net_connect!
    @adsense = Adsense::AdSenseService.new
    @adsense.authorization = Google::Auth.get_application_default([Adsense::AUTH_ADSENSE])
    @adsense.authorization.sub = 'cb@travelingnuker.com'
    @adsense.authorization.fetch_access_token!
  end

  it 'should download a report with multiple dimensions' do
    Faraday::Utils.default_params_encoder = Faraday::FlatParamsEncoder

    report = @adsense.generate_report( Date.today.to_s, Date.today.to_s, dimension: ["DATE", "AD_UNIT_NAME"] )

    report_header_names = report.headers.map { |h| h.name }
    expect(report_header_names).to include('DATE')
    expect(report_header_names).to include('AD_UNIT_NAME')
  end

  after(:context) do
    WebMock.disable_net_connect!
  end
end

This seems to be a Hurley problem of some sort. Here is my output from the test:

Google::Apis::AdsenseV1_4
D, [2015-10-01T21:39:43.779868 #95231] DEBUG -- : Sending HTTP get https://www.googleapis.com/adsense/v1.4/reports?dimension=DATE&dimension=AD_UNIT_NAME&endDate=2015-10-01&startDate=2015-10-01
false
D, [2015-10-01T21:39:44.003804 #95231] DEBUG -- : 200
D, [2015-10-01T21:39:44.004072 #95231] DEBUG -- : #<Hurley::Response GET https://www.googleapis.com/adsense/v1.4/reports?dimension=AD_UNIT_NAME&endDate=2015-10-01&startDate=2015-10-01 == 200 (232 bytes) 208ms>
D, [2015-10-01T21:39:44.006211 #95231] DEBUG -- : Success - #<Google::Apis::AdsenseV1_4::GenerateReportResponse:0x000000026c0118
 @averages=[""],
 @end_date="2015-10-01",
 @headers=
  [#<Google::Apis::AdsenseV1_4::GenerateReportResponse::Header:0x00000002657d20
    @name="AD_UNIT_NAME",
    @type="DIMENSION">],
 @kind="adsense#report",
 @start_date="2015-10-01",
 @total_matched_rows="0",
 @totals=[""]>

You can see on line 2 that the query string is correct there. After passed to Hurley, there is only one dimension left on line 4.

Thank you for your time. Please advise.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

🚨This issue needs some love.triage meI really want to be triaged.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions