Permalink
Browse files

Google client returns an array of responses

  • Loading branch information...
1 parent 5ca06bb commit 120686f6741848b6ed669dfc2c479b5e849e509d Pawel Badenski committed Jan 21, 2013
Showing with 6 additions and 4 deletions.
  1. +1 −1 lib/client.rb
  2. +2 −1 lib/collector.rb
  3. +3 −2 spec/integration/google_analytics_client_spec.rb
View
@@ -29,7 +29,7 @@ def query(parameters)
raise "Response error [#{response.error_message}]" if response.error?
- JSON.parse(response.body)
+ [JSON.parse(response.body)]
end
def client
View
@@ -66,9 +66,10 @@ def collect_response(config)
def collect(config)
google_analytics_client = GoogleAnalytics::Client.new(@auth_code)
- config.analytics_parameters.map do |parameters|
+ results = config.analytics_parameters.map do |parameters|
google_analytics_client.query(parameters)
end
+ results.flatten
end
end
@@ -13,11 +13,12 @@
client = GoogleAnalytics::Client.new("some-auth-code")
- data = client.query({ "ids" => "ga:0",
+ responses = client.query({ "ids" => "ga:0",
"metrics" => "ga:stub-metric",
"start-date" => "2012-01-01",
"end-date" => "2012-01-31" })
- data["rows"].should_not be_empty
+ responses.should have(1).response
+ responses.first["rows"].should have(2).rows
end
end

1 comment on commit 120686f

@robyoung
Contributor

It might just be because it's late but, why?

Please sign in to comment.