Przeglądaj źródła

merge r25023 from trunk to release-1.12 for Gdata updates

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25024 44c647ce-9c0f-0410-b52a-842ac1e357ba
rob 13 lat temu
rodzic
commit
2e33476195

+ 33 - 18
library/Zend/Gdata/Analytics.php

@@ -51,6 +51,11 @@ require_once 'Zend/Gdata/Analytics/DataFeed.php';
 require_once 'Zend/Gdata/Analytics/DataQuery.php';
 
 /**
+ * @see Zend_Gdata_Analytics_AccountQuery
+ */
+require_once 'Zend/Gdata/Analytics/AccountQuery.php';
+
+/**
  * @category   Zend
  * @package    Zend_Gdata
  * @subpackage Analytics
@@ -58,13 +63,14 @@ require_once 'Zend/Gdata/Analytics/DataQuery.php';
 class Zend_Gdata_Analytics extends Zend_Gdata
 {
 
-	const AUTH_SERVICE_NAME = 'analytics';
-	const ANALYTICS_FEED_URI = 'https://www.google.com/analytics/feeds';
-	const ANALYTICS_ACCOUNT_FEED_URI = 'https://www.google.com/analytics/feeds/accounts';
+    const AUTH_SERVICE_NAME = 'analytics';
+    const ANALYTICS_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/data';
+    const ANALYTICS_ACCOUNT_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/management/accounts';
 
-	public static $namespaces = array(
-        array('ga', 'http://schemas.google.com/analytics/2009', 1, 0)
-    );
+    public static $namespaces = array(
+        array('analytics', 'http://schemas.google.com/analytics/2009', 1, 0),
+        array('ga', 'http://schemas.google.com/ga/2009', 1, 0)
+     );
 
     /**
      * Create Gdata object
@@ -83,29 +89,28 @@ class Zend_Gdata_Analytics extends Zend_Gdata
 
     /**
      * Retrieve account feed object
-     *
+     * 
+     * @param string|Zend_Uri_Uri $uri
      * @return Zend_Gdata_Analytics_AccountFeed
      */
-    public function getAccountFeed()
+    public function getAccountFeed($uri = self::ANALYTICS_ACCOUNT_FEED_URI)
     {
-        $uri = self::ANALYTICS_ACCOUNT_FEED_URI . '/default?prettyprint=true';
+        if ($uri instanceof Query) {
+            $uri = $uri->getQueryUrl();
+        }
         return parent::getFeed($uri, 'Zend_Gdata_Analytics_AccountFeed');
     }
 
     /**
      * Retrieve data feed object
      * 
-     * @param mixed $location
+     * @param string|Zend_Uri_Uri $uri
      * @return Zend_Gdata_Analytics_DataFeed
      */
-    public function getDataFeed($location)
+    public function getDataFeed($uri = self::ANALYTICS_FEED_URI)
     {
-		if ($location == null) {
-            $uri = self::ANALYTICS_FEED_URI;
-        } elseif ($location instanceof Zend_Gdata_Query) {
-            $uri = $location->getQueryUrl();
-        } else {
-            $uri = $location;
+        if ($uri instanceof Query) {
+            $uri = $uri->getQueryUrl();
         }
         return parent::getFeed($uri, 'Zend_Gdata_Analytics_DataFeed');
     }
@@ -117,6 +122,16 @@ class Zend_Gdata_Analytics extends Zend_Gdata
      */
     public function newDataQuery()
     {
-    	return new Zend_Gdata_Analytics_DataQuery();
+        return new Zend_Gdata_Analytics_DataQuery();
+    }
+    
+    /**
+     * Returns a new AccountQuery object.
+     *
+     * @return Zend_Gdata_Analytics_AccountQuery
+     */
+    public function newAccountQuery()
+    {
+        return new Zend_Gdata_Analytics_AccountQuery();
     }
 }

+ 28 - 21
library/Zend/Gdata/Analytics/AccountEntry.php

@@ -52,18 +52,20 @@ require_once 'Zend/Gdata/Analytics/Extension/TableId.php';
  */
 class Zend_Gdata_Analytics_AccountEntry extends Zend_Gdata_Entry
 {
-	protected $_accountId;
-	protected $_accountName;
-	protected $_profileId;
-	protected $_webPropertyId;
-	protected $_currency;
-	protected $_timezone;
-	protected $_tableId;
+    protected $_accountId;
+    protected $_accountName;
+    protected $_profileId;
+    protected $_webPropertyId;
+    protected $_currency;
+    protected $_timezone;
+    protected $_tableId;
+    protected $_profileName;
+    protected $_goal;
 
-	/**
-	 * @see Zend_Gdata_Entry::__construct()
-	 */
-	public function __construct($element = null)
+    /**
+     * @see Zend_Gdata_Entry::__construct()
+     */
+    public function __construct($element = null)
     {
         $this->registerAllNamespaces(Zend_Gdata_Analytics::$namespaces);
         parent::__construct($element);
@@ -77,18 +79,23 @@ class Zend_Gdata_Analytics_AccountEntry extends Zend_Gdata_Entry
     {
         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
         switch ($absoluteNodeName){
-        	case $this->lookupNamespace('ga') . ':' . 'property';
-	            $property = new Zend_Gdata_Analytics_Extension_Property();
-	            $property->transferFromDOM($child);
-	            $this->{$property->getName()} = $property;
+            case $this->lookupNamespace('analytics') . ':' . 'property';
+                $property = new Zend_Gdata_Analytics_Extension_Property();
+                $property->transferFromDOM($child);
+                $this->{$property->getName()} = $property;
+                break;
+            case $this->lookupNamespace('analytics') . ':' . 'tableId';
+                $tableId = new Zend_Gdata_Analytics_Extension_TableId();
+                $tableId->transferFromDOM($child);
+                $this->_tableId = $tableId;
                 break;
-        	case $this->lookupNamespace('ga') . ':' . 'tableId';
-	            $tableId = new Zend_Gdata_Analytics_Extension_TableId();
-	            $tableId->transferFromDOM($child);
-	            $this->_tableId = $tableId;
+            case $this->lookupNamespace('ga') . ':' . 'goal';
+                $goal = new Zend_Gdata_Analytics_Extension_Goal();
+                $goal->transferFromDOM($child);
+                $this->_goal = $goal;
                 break;
-        	default:
-            	parent::takeChildFromDOM($child);
+            default:
+                parent::takeChildFromDOM($child);
                 break;
         }
     }

+ 190 - 0
library/Zend/Gdata/Analytics/AccountQuery.php

@@ -0,0 +1,190 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Gdata
+ * @subpackage Analytics
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+/**
+ * @see Zend_Gdata_Query
+ */
+require_once 'Zend/Gdata/Query.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Gdata
+ * @subpackage Analytics
+ */
+class Zend_Gdata_Analytics_AccountQuery extends Zend_Gdata_Query
+{
+    const ANALYTICS_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/management/accounts';
+
+    /**
+     * The default URI used for feeds.
+     */
+    protected $_defaultFeedUri = self::ANALYTICS_FEED_URI;
+    
+    /**
+     * @var string
+     */
+    protected $_accountId = '~all';
+    /**
+     * @var string
+     */
+    protected $_webpropertyId = '~all';
+    /**
+     * @var string
+     */
+    protected $_profileId = '~all';
+   
+    /**
+     * @var bool
+     */ 
+    protected $_webproperties = false;
+    /**
+     * @var bool
+     */
+    protected $_profiles = false;
+    /**
+     * @var bool
+     */
+    protected $_goals = false;
+    
+    /**
+     * @param string $accountId
+     * @return Zend_Gdata_Analytics_AccountQuery
+     */
+    public function setAccountId($accountId)
+    {
+        $this->_accountId = $accountId;
+        return $this;
+    }
+    
+    /**
+     * @return string
+     */
+    public function getAccountId()
+    {
+        return $this->_accountId;
+    }
+
+    /**
+     * @param string $webpropertyId
+     * @return Zend_Gdata_Analytics_AccountQuery
+     */
+    public function setWebpropertyId($webpropertyId)
+    {
+        $this->_webpropertyId = $webpropertyId;
+        return $this;
+    }
+    
+    /**
+     * @return string
+     */
+    public function getWebpropertyId()
+    {
+        return $this->_webpropertyId;
+    }
+    
+    /**
+     * @param string $profileId
+     * @return Zend_Gdata_Analytics_AccountQuery
+     */
+    public function setProfileId($profileId)
+    {
+        $this->_profileId = $profileId;
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getProfileId()
+    {
+        return $this->_profileId;
+    }
+    
+    /**
+     * @param string $accountId
+     * @return Zend_Gdata_Analytics_AccountQuery
+     */
+    public function webproperties($accountId = '~all')
+    {
+        $this->_webproperties = true;
+        $this->setAccountId($accountId);    
+        return $this;
+    }
+    
+    /**
+     * @param string $webpropertyId
+     * @param string $accountId
+     * @return Zend_Gdata_Analytics_AccountQuery
+     */
+    public function profiles($webpropertyId = '~all', $accountId = '~all')
+    {
+        $this->_profiles = true;
+        if (null !== $accountId) {
+            $this->setAccountId($accountId);    
+        }
+        $this->setWebpropertyId($webpropertyId);
+        return $this;
+    }
+    
+    /**
+     * @param string $webpropertyId
+     * @param string $accountId
+     * @param string $accountId
+     * @return Zend_Gdata_Analytics_AccountQuery
+     */
+    public function goals($profileId = '~all', $webpropertyId = '~all', $accountId = '~all')
+    {
+        $this->_goals = true;
+        if (null !== $accountId) {
+            $this->setAccountId($accountId);    
+        }
+        if (null !== $webpropertyId) {
+            $this->setWebpropertyId($webpropertyId);    
+        }
+        $this->setProfileId($profileId);
+        return $this;
+    }
+    
+    /**
+     * @return string url
+     */
+    public function getQueryUrl()
+    {
+        $url = $this->_defaultFeedUri;
+        
+        // add account id
+        if ($this->_webproperties or $this->_profiles or $this->_goals) {
+            $url .= '/' . $this->_accountId . '/webproperties';
+        }
+        
+        if ($this->_profiles or $this->_goals) {
+            $url .= '/' . $this->_webpropertyId . '/profiles';
+        }
+        
+        if ($this->_goals) {
+            $url .= '/' . $this->_profileId . '/goals';
+        }
+
+        $url .= $this->getQueryString();
+        return $url;
+    }
+}

+ 61 - 61
library/Zend/Gdata/Analytics/DataEntry.php

@@ -32,25 +32,25 @@ require_once 'Zend/Gdata/Entry.php';
  */
 class Zend_Gdata_Analytics_DataEntry extends Zend_Gdata_Entry
 {
-	/**
-	 * @var array
-	 */
-	protected $_dimensions = array();
-	/**
-	 * @var array
-	 */
-	protected $_metrics = array();
+    /**
+     * @var array
+     */
+    protected $_dimensions = array();
+    /**
+     * @var array
+     */
+    protected $_metrics = array();
 
-	/**
-	 * @param DOMElement $element
-	 */
+    /**
+     * @param DOMElement $element
+     */
     public function __construct($element = null)
     {
         $this->registerAllNamespaces(Zend_Gdata_Analytics::$namespaces);
         parent::__construct($element);
     }
 
-	/**
+    /**
      * @param DOMElement $child
      * @return void
      */
@@ -58,59 +58,59 @@ class Zend_Gdata_Analytics_DataEntry extends Zend_Gdata_Entry
     {
         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
         switch ($absoluteNodeName) {
-        	case $this->lookupNamespace('ga') . ':' . 'dimension';
-	            $dimension = new Zend_Gdata_Analytics_Extension_Dimension();
-	            $dimension->transferFromDOM($child);
-	            $this->_dimensions[] = $dimension;
+            case $this->lookupNamespace('analytics') . ':' . 'dimension';
+                $dimension = new Zend_Gdata_Analytics_Extension_Dimension();
+                $dimension->transferFromDOM($child);
+                $this->_dimensions[] = $dimension;
                 break;
-        	case $this->lookupNamespace('ga') . ':' . 'metric';
-	            $metric = new Zend_Gdata_Analytics_Extension_Metric();
-	            $metric->transferFromDOM($child);
-	            $this->_metrics[] = $metric;
+            case $this->lookupNamespace('analytics') . ':' . 'metric';
+                $metric = new Zend_Gdata_Analytics_Extension_Metric();
+                $metric->transferFromDOM($child);
+                $this->_metrics[] = $metric;
                 break;
-        	default:
-            	parent::takeChildFromDOM($child);
+            default:
+                parent::takeChildFromDOM($child);
                 break;
         }
     }
 
-	/**
-	 * @param string $name 
-	 * @return mixed
-	 */
-	public function getDimension($name)
-	{
-		foreach ($this->_dimensions as $dimension) {
-			if ($dimension->getName() == $name) {
-				return $dimension;
-			}
-		}
-		return null;
-	}
-	
-	/** 
-	 * @param string $name 
-	 * @return mixed
-	 */
-	public function getMetric($name)
-	{
-		foreach ($this->_metrics as $metric) {
-			if ($metric->getName() == $name) {
-				return $metric;
-			}
-		}
-		return null;
-	}
-	
-	/**
-	 * @param string $name 
-	 * @return mixed
-	 */
-	public function getValue($name)
-	{
-		if (null !== ($metric = $this->getMetric($name))) {
-			return $metric;
-		}
-		return $this->getDimension($name);
-	}
+    /**
+     * @param string $name 
+     * @return mixed
+     */
+    public function getDimension($name)
+    {
+        foreach ($this->_dimensions as $dimension) {
+            if ($dimension->getName() == $name) {
+                return $dimension;
+            }
+        }
+        return null;
+    }
+    
+    /** 
+     * @param string $name 
+     * @return mixed
+     */
+    public function getMetric($name)
+    {
+        foreach ($this->_metrics as $metric) {
+            if ($metric->getName() == $name) {
+                return $metric;
+            }
+        }
+        return null;
+    }
+    
+    /**
+     * @param string $name 
+     * @return mixed
+     */
+    public function getValue($name)
+    {
+        if (null !== ($metric = $this->getMetric($name))) {
+            return $metric;
+        }
+        return $this->getDimension($name);
+    }
 }

+ 1 - 21
library/Zend/Gdata/Analytics/DataQuery.php

@@ -32,7 +32,7 @@ require_once 'Zend/Gdata/Query.php';
  */
 class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query
 {
-    const ANALYTICS_FEED_URI = 'http://www.google.com/analytics/feeds/data';
+    const ANALYTICS_FEED_URI = 'https://www.googleapis.com/analytics/v2.4/data';
 
     /**
      * The default URI used for feeds.
@@ -327,15 +327,6 @@ class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query
     }
     
     /**
-     * @deprecated
-     * @param string $value
-     * @return Zend_Gdata_Analytics_DataQuery
-     */
-    public function setFilter($value)
-    {
-        return $this->addFilter($value);
-    }
-    /**
      * @param string $sort
      * @param boolean[optional] $descending
      * @return Zend_Gdata_Analytics_DataQuery
@@ -348,17 +339,6 @@ class Zend_Gdata_Analytics_DataQuery extends Zend_Gdata_Query
     }
     
     /**
-     * @deprecated
-     * @param string $sort
-     * @param boolean[optional] $descending
-     * @return Zend_Gdata_Analytics_DataQuery
-     */
-    public function setSort($sort, $descending=false)
-    {
-        return $this->addSort($sort, $descending);
-    }
-    
-    /**
      * @return Zend_Gdata_Analytics_DataQuery
      */
     public function clearSort()

+ 52 - 0
library/Zend/Gdata/Analytics/Extension/Goal.php

@@ -0,0 +1,52 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Gdata
+ * @subpackage Analytics
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+/**
+ * @see Zend_Gdata_Extension
+ */
+require_once 'Zend/Gdata/Extension.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Gdata
+ * @subpackage Analytics
+ */
+class Zend_Gdata_Analytics_Goal extends Zend_Gdata_Extension
+{
+    protected $_rootNamespace = 'ga';
+    protected $_rootElement = 'goal';
+
+    public function __construct()
+    {
+        $this->registerAllNamespaces(Zend_Gdata_Analytics::$namespaces);
+        parent::__construct();
+    }
+    
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        $attribs = $this->getExtensionAttributes();
+        return $attribs['name']['value'];
+    }
+}

+ 9 - 9
library/Zend/Gdata/Analytics/Extension/Metric.php

@@ -38,17 +38,17 @@ class Zend_Gdata_Analytics_Extension_Metric
     protected $_value = null;
     protected $_name = null;
 
-	protected function takeAttributeFromDOM($attribute)
+    protected function takeAttributeFromDOM($attribute)
     {
         switch ($attribute->localName) {
-	        case 'name':
-	        	$this->_name = $attribute->nodeValue;
-		        break;
-	        case 'value':
-	            $this->_value = $attribute->nodeValue;
-	            break;
-	        default:
-	            parent::takeAttributeFromDOM($attribute);
+            case 'name':
+                $this->_name = $attribute->nodeValue;
+                break;
+            case 'value':
+                $this->_value = $attribute->nodeValue;
+                break;
+            default:
+                parent::takeAttributeFromDOM($attribute);
         }
     }
 }

+ 6 - 5
library/Zend/Gdata/Analytics/Extension/Property.php

@@ -60,8 +60,9 @@ class Zend_Gdata_Analytics_Extension_Property extends Zend_Gdata_Extension
     {
         switch ($attribute->localName) {
             case 'name':
-            	$this->_name = substr($attribute->nodeValue, 3);
-    	        break;
+                $name = explode(':', $attribute->nodeValue);
+                $this->_name = end($name);
+                break;
             case 'value':
                 $this->_value = $attribute->nodeValue;
                 break;
@@ -98,8 +99,8 @@ class Zend_Gdata_Analytics_Extension_Property extends Zend_Gdata_Extension
      */
     public function setName($name)
     {
-    	$this->_name = $name;
-    	return $this;
+        $this->_name = $name;
+        return $this;
     }
 
     /**
@@ -107,7 +108,7 @@ class Zend_Gdata_Analytics_Extension_Property extends Zend_Gdata_Extension
      */
     public function getName()
     {
-    	return $this->_name;
+        return $this->_name;
     }
 
     /**

+ 3 - 0
tests/Zend/Gdata/AllTests.php

@@ -33,6 +33,9 @@ require_once 'Zend/Gdata/AuthSubTest.php';
  * 
  */
 require_once 'Zend/Gdata/Analytics/AccountFeedTest.php';
+require_once 'Zend/Gdata/Analytics/AccountQueryTest.php';
+require_once 'Zend/Gdata/Analytics/DataFeedTest.php';
+require_once 'Zend/Gdata/Analytics/DataQueryTest.php';
 
 /**
  * Tests that do not require online access to servers

+ 22 - 5
tests/Zend/Gdata/Analytics/AccountFeedTest.php

@@ -34,21 +34,38 @@ require_once 'Zend/Http/Client.php';
  */
 class Zend_Gdata_Analytics_AccountFeedTest extends PHPUnit_Framework_TestCase
 {
+    /** @var AccountFeed */
+    public $accountFeed;
 
     public function setUp()
     {
         $this->accountFeed = new Zend_Gdata_Analytics_AccountFeed(
-            file_get_contents(dirname(__FILE__) . '/_files/TestAccountFeed.xml'),
-            true
+            file_get_contents(dirname(__FILE__) . '/_files/TestAccountFeed.xml')
         );
     }
 
     public function testAccountFeed()
     {
-        $this->assertEquals(count($this->accountFeed->entries), 3);
-        $this->assertEquals($this->accountFeed->entries->count(), 3);
+        $this->assertEquals(2, count($this->accountFeed->entries));
+
         foreach ($this->accountFeed->entries as $entry) {
-            $this->assertTrue($entry instanceof Zend_Gdata_Analytics_AccountEntry);
+            $this->assertInstanceOf('Zend_Gdata_Analytics_AccountEntry', $entry);
         }
     }
+
+	public function testFirstAccountProperties()
+    {
+        $account = $this->accountFeed->entries[0];
+        $this->assertEquals(876543, "{$account->accountId}");
+        $this->assertEquals('foobarbaz', "{$account->accountName}");
+        $this->assertInstanceOf('Zend_GData_App_Extension_Link', $account->link[0]);
+    }
+
+    public function testSecondAccountProperties()
+    {
+        $account = $this->accountFeed->entries[1];
+        $this->assertEquals(23456789, "{$account->accountId}");
+        $this->assertEquals('brain dump', "{$account->accountName}");
+        $this->assertInstanceOf('Zend_GData_App_Extension_Link', $account->link[0]);
+    }
 }

+ 126 - 0
tests/Zend/Gdata/Analytics/AccountQueryTest.php

@@ -0,0 +1,126 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Gdata_Analytics
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+require_once 'Zend/Gdata/Analytics.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Gdata_Analytics
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @group      Zend_Gdata
+ * @group      Zend_Gdata_Analytics
+ */
+class Zend_GData_Analytics_AccountQueryTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * @var Zend_GData_Analytics_AccountQuery
+     */
+    public $accountQuery;
+
+    public function setUp()
+    {
+        $this->accountQuery = new Zend_GData_Analytics_AccountQuery();
+        $this->queryBase = Zend_GData_Analytics_AccountQuery::ANALYTICS_FEED_URI;
+    }
+
+    public function testWebpropertiesAll()
+    {
+        $this->accountQuery->webproperties();
+        $allQuery = $this->accountQuery->getQueryUrl();
+        
+        $this->assertEquals(
+            $this->queryBase . '/~all/webproperties', 
+            $allQuery
+        );
+    }
+    
+    public function testWebpropertiesSpecific()
+    {
+        $this->accountQuery->webproperties(12345678);
+        $specificQuery = $this->accountQuery->getQueryUrl();
+        
+        $this->assertEquals(
+            $this->queryBase . '/12345678/webproperties', 
+            $specificQuery
+        );
+    }
+    
+    public function testProfilesAll()
+    {
+        $this->accountQuery->profiles();
+        $allQuery = $this->accountQuery->getQueryUrl();
+        
+        $this->assertEquals(
+            $this->queryBase . '/~all/webproperties/~all/profiles', 
+            $allQuery
+        );
+    }
+    
+    public function testProfilesSpecific()
+    {
+        $this->accountQuery->profiles('U-87654321-0', 87654321);
+        $specificQuery = $this->accountQuery->getQueryUrl();
+        
+        $this->assertEquals(
+            $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles', 
+            $specificQuery
+        );
+    }
+    
+    public function testGoalsAll()
+    {
+        $this->accountQuery->goals();
+        $allQuery = $this->accountQuery->getQueryUrl();
+        
+        $this->assertEquals(
+            $this->queryBase . '/~all/webproperties/~all/profiles/~all/goals', 
+            $allQuery
+        );
+    }
+    
+    public function testGoalsSpecific()
+    {
+        $this->accountQuery->goals(42, 'U-87654321-0', 87654321);
+        $specificQuery = $this->accountQuery->getQueryUrl();
+        
+        $this->assertEquals(
+            $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles/42/goals', 
+            $specificQuery
+        );
+    }
+    
+    public function testChainedProperties()
+    {
+        $this->accountQuery
+            ->goals(42)
+            ->profiles('U-87654321-0')
+            ->webproperties(87654321);
+        $specificQuery = $this->accountQuery->getQueryUrl();
+        
+        $this->assertEquals(
+            $this->queryBase . '/87654321/webproperties/U-87654321-0/profiles/42/goals', 
+            $specificQuery
+        );
+    }
+}

+ 12 - 12
tests/Zend/Gdata/Analytics/DataFeedTest.php

@@ -35,18 +35,18 @@ require_once 'Zend/Http/Client.php';
 class Zend_Gdata_Analytics_DataFeedTest extends PHPUnit_Framework_TestCase
 {
     public $testData = array(
-        'blogger.com' => 68140,
-        'google.com'  => 29666,
-        'stumbleupon.com' => 4012, 
-        'google.co.uk' => 2968, 
-        'google.co.in' => 2793,        
+        'foobarbaz.de' => 12,
+        'foobar.de' => 3,
+        'foobarbaz.ch' => 1,
+        'baz.ch' => 1,
     );
-    
+    /** @var DataFeed */
+    public $dataFeed;
+
     public function setUp()
     {
         $this->dataFeed = new Zend_Gdata_Analytics_DataFeed(
-            file_get_contents(dirname(__FILE__) . '/_files/TestDataFeed.xml'),
-            true
+            file_get_contents(dirname(__FILE__) . '/_files/TestDataFeed.xml')
         );
     }
 
@@ -59,18 +59,18 @@ class Zend_Gdata_Analytics_DataFeedTest extends PHPUnit_Framework_TestCase
             $this->assertTrue($entry instanceof Zend_Gdata_Analytics_DataEntry);
         }
     }
-    
+
     public function testGetters()
     {
         $sources = array_keys($this->testData);
         $values = array_values($this->testData);
-        
+
         foreach ($this->dataFeed as $index => $row) {
-            $source = $row->getDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_SOURCE);
+            $source = $row->getDimension(Zend_Gdata_Analytics_DataQuery::DIMENSION_SOURCE);
             $medium = $row->getDimension('ga:medium');
             $visits = $row->getMetric('ga:visits');
             $visitsValue = $row->getValue('ga:visits');
-            
+
             $this->assertEquals("$medium", 'referral');
             $this->assertEquals("$source", $sources[$index]);
             $this->assertEquals("$visits", $values[$index]);

+ 101 - 0
tests/Zend/Gdata/Analytics/DataQueryTest.php

@@ -0,0 +1,101 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Gdata_Analytics
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+require_once 'Zend/Gdata/Analytics.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Gdata_Analytics
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @group      Zend_Gdata
+ * @group      Zend_Gdata_Analytics
+ */
+class Zend_GData_Analytics_DataQueryTest extends PHPUnit_Framework_TestCase
+{
+
+    /**
+     * @var Zend_GData_Analytics_DataQuery
+     */
+    public $dataQuery;
+
+    public function setUp()
+    {
+        $this->dataQuery = new Zend_GData_Analytics_DataQuery();
+    }
+
+    public function testProfileId()
+    {
+        $this->assertTrue($this->dataQuery->getProfileId() == null);
+        $this->dataQuery->setProfileId(123456);
+        $this->assertTrue($this->dataQuery->getProfileId() == 123456);
+    }
+
+    public function testAddMetric()
+    {
+        $this->assertTrue(count($this->dataQuery->getMetrics()) == 0);
+        $this->dataQuery->addMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES);
+        $this->assertTrue(count($this->dataQuery->getMetrics()) == 1);
+    }
+
+    public function testAddAndRemoveMetric()
+    {
+        $this->dataQuery->addMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES);
+        $this->dataQuery->removeMetric(Zend_GData_Analytics_DataQuery::METRIC_BOUNCES);
+        $this->assertTrue(count($this->dataQuery->getMetrics()) == 0);
+    }
+
+    public function testAddDimension()
+    {
+        $this->assertTrue(count($this->dataQuery->getDimensions()) == 0);
+        $this->dataQuery->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT);
+        $this->assertTrue(count($this->dataQuery->getDimensions()) == 1);
+    }
+
+    public function testAddAndRemoveDimension()
+    {
+        $this->dataQuery->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT);
+        $this->dataQuery->removeDimension(Zend_GData_Analytics_DataQuery::DIMENSION_AD_SLOT);
+        $this->assertTrue(count($this->dataQuery->getDimensions()) == 0);
+    }
+
+    public function testQueryString()
+    {
+        $this->dataQuery
+            ->setProfileId(123456789)
+            ->addFilter('foo=bar')
+            ->addFilter('bar>2')
+            ->addOrFilter('baz=42')
+            ->addDimension(Zend_GData_Analytics_DataQuery::DIMENSION_CITY)
+            ->addMetric(Zend_GData_Analytics_DataQuery::METRIC_PAGEVIEWS)
+            ->addMetric(Zend_GData_Analytics_DataQuery::METRIC_VISITS);
+        $url = parse_url($this->dataQuery->getQueryUrl());
+        parse_str($url['query'], $parameter);
+
+        $this->assertEquals(count($parameter), 4);
+        $this->assertEquals($parameter['ids'], "ga:123456789");
+        $this->assertEquals($parameter['dimensions'], "ga:city");
+        $this->assertEquals($parameter['metrics'], "ga:pageviews,ga:visits");
+        $this->assertEquals($parameter['filters'], 'foo=bar;bar>2,baz=42');
+    }
+}

+ 32 - 110
tests/Zend/Gdata/Analytics/_files/TestAccountFeed.xml

@@ -1,110 +1,32 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<feed xmlns='http://www.w3.org/2005/Atom' xmlns:dxp='http://schemas.google.com/analytics/2009' xmlns:ga='http://schemas.google.com/ga/2009' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;DUcCRX47eCp7I2A9WxNbFkk.&quot;' gd:kind='analytics#accounts'>
-        <id>http://www.google.com/analytics/feeds/accounts/abc@test.com</id>
-        <updated>2009-11-19T08:11:04.000-08:00</updated>
-        <title>Profile list for abc@test.com</title>
-        <link rel='self' type='application/atom+xml' href='http://www.google.com/analytics/feeds/accounts/default'/>
-        <author>
-                <name>Google Analytics</name>
-        </author>
-        <generator version='1.0'>Google Analytics</generator>
-        <openSearch:totalResults>41</openSearch:totalResults>
-        <openSearch:startIndex>1</openSearch:startIndex>
-        <openSearch:itemsPerPage>3</openSearch:itemsPerPage>
-        <dxp:segment id='gaid::-1' name='All Visits'>
-                <dxp:definition> </dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-2' name='New Visitors'>
-                <dxp:definition>ga:visitorType==New Visitor</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-3' name='Returning Visitors'>
-                <dxp:definition>ga:visitorType==Returning Visitor</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-4' name='Paid Search Traffic'>
-                <dxp:definition>ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==ppc</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-5' name='Non-paid Search Traffic'>
-                <dxp:definition>ga:medium==organic</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-6' name='Search Traffic'>
-                <dxp:definition>ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-7' name='Direct Traffic'>
-                <dxp:definition>ga:medium==(none)</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-8' name='Referral Traffic'>
-                <dxp:definition>ga:medium==referral</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-9' name='Visits with Conversions'>
-                <dxp:definition>ga:goalCompletionsAll&gt;0</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-10' name='Visits with Transactions'>
-                <dxp:definition>ga:transactions&gt;0</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-11' name='Visits from iPhones'>
-                <dxp:definition>ga:operatingSystem==iPhone</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::-12' name='Non-bounce Visits'>
-                <dxp:definition>ga:bounces==0</dxp:definition>
-        </dxp:segment>
-        <dxp:segment id='gaid::0' name='Sources Form Google'>
-                <dxp:definition>ga:source=~^\Qgoogle\E</dxp:definition>
-        </dxp:segment>
-        <entry gd:etag='W/&quot;DUcCRX47eCp7I2A9WxNbFkk.&quot;' gd:kind='analytics#account'>
-                <id>http://www.google.com/analytics/feeds/accounts/ga:1174</id>
-                <updated>2009-11-19T08:11:04.000-08:00</updated>
-                <title>www.googlestore.com</title>
-                <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/>
-                <ga:goal active='true' name='Completing Order' number='1' value='10.0'>
-                        <ga:destination caseSensitive='false' expression='/purchaseComplete.html' matchType='regex' step1Required='false'>
-                                <ga:step name='View Product Categories' number='1' path='/Apps|Accessories'/>
-                                <ga:step name='View Product' number='2' path='/Apps|Accessories/(.*)\.axd'/>
-                                <ga:step name='View Shopping Cart' number='3' path='/shoppingcart.aspx'/>
-                                <ga:step name='Login' number='4' path='/login.html'/>
-                                <ga:step name='Place Order' number='5' path='/placeOrder.html'/>
-                        </ga:destination>
-                </ga:goal>
-                <ga:goal active='true' name='Browsed my site over 5 minutes' number='2' value='0.0'>
-                        <ga:engagement comparison='&gt;' thresholdValue='300' type='timeOnSite'/>
-                </ga:goal>
-                <ga:goal active='true' name='Visited &gt; 4 pages' number='3' value='0.25'>
-                        <ga:engagement comparison='&gt;' thresholdValue='4' type='pagesVisited'/>
-                </ga:goal>
-                <dxp:property name='ga:accountId' value='30481'/>
-                <dxp:property name='ga:accountName' value='Google Store'/>
-                <dxp:property name='ga:profileId' value='1174'/>
-                <dxp:property name='ga:webPropertyId' value='UA-30481-1'/>
-                <dxp:property name='ga:currency' value='USD'/>
-                <dxp:property name='ga:timezone' value='America/Los_Angeles'/>
-                <dxp:tableId>ga:1174</dxp:tableId>
-        </entry>
-        <entry gd:etag='W/&quot;DkEASH47eCp7I2A9WxNbFUo.&quot;' gd:kind='analytics#account'>
-                <id>http://www.google.com/analytics/feeds/accounts/ga:11380020</id>
-                <updated>2009-11-18T12:04:09.000-08:00</updated>
-                <title>Googlestore - overall</title>
-                <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/>
-                <ga:goal active='false' name='goal2.html' number='1' value='0.0'>
-                        <ga:destination caseSensitive='false' expression='/goal2.html' matchType='head' step1Required='false'/>
-                </ga:goal>
-                <dxp:property name='ga:accountId' value='30481'/>
-                <dxp:property name='ga:accountName' value='Google Store'/>
-                <dxp:property name='ga:profileId' value='11380020'/>
-                <dxp:property name='ga:webPropertyId' value='UA-30481-1'/>
-                <dxp:property name='ga:currency' value='USD'/>
-                <dxp:property name='ga:timezone' value='America/Los_Angeles'/>
-                <dxp:tableId>ga:11380020</dxp:tableId>
-        </entry>
-        <entry gd:etag='W/&quot;C04HRn47eCp7I2A9WxJbGUQ.&quot;' gd:kind='analytics#account'>
-                <id>http://www.google.com/analytics/feeds/accounts/ga:11380025</id>
-                <updated>2009-07-30T15:12:17.000-07:00</updated>
-                <title>Googlestore - no filters</title>
-                <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/>
-                <dxp:property name='ga:accountId' value='30481'/>
-                <dxp:property name='ga:accountName' value='Google Store'/>
-                <dxp:property name='ga:profileId' value='11380025'/>
-                <dxp:property name='ga:webPropertyId' value='UA-30481-1'/>
-                <dxp:property name='ga:currency' value='USD'/>
-                <dxp:property name='ga:timezone' value='America/Los_Angeles'/>
-                <dxp:tableId>ga:11380025</dxp:tableId>
-        </entry>
-</feed>
+<?xml version="1.0" encoding="UTF-8"?>
+<feed gd:kind="analytics#accounts" xmlns="http://www.w3.org/2005/Atom" xmlns:dxp="http://schemas.google.com/analytics/2009" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">
+    <id>https://www.googleapis.com/analytics/v2.4/management/accounts</id>
+    <updated>2012-07-13T16:53:15.150Z</updated>
+    <title type="text">Google Analytics Accounts for mail@storkki.de</title>
+    <link rel="self" type="application/atom+xml" href="https://www.googleapis.com/analytics/v2.4/management/accounts" />
+    <author>
+        <name>Google Analytics</name>
+    </author>
+    <generator>Google Analytics</generator>
+    <openSearch:totalResults>2</openSearch:totalResults>
+    <openSearch:startIndex>1</openSearch:startIndex>
+    <openSearch:itemsPerPage>1000</openSearch:itemsPerPage>
+    <entry gd:kind="analytics#account">
+        <id>https://www.googleapis.com/analytics/v2.4/management/accounts/876543</id>
+        <updated>2010-03-02T16:04:23.720Z</updated>
+        <title type="text">Google Analytics Account foobarbaz</title>
+        <link rel="self" type="application/atom+xml" href="https://www.googleapis.com/analytics/v2.4/management/accounts/876543" />
+        <link rel="http://schemas.google.com/ga/2009#child" type="application/atom+xml" gd:targetKind="analytics#webproperties" href="https://www.googleapis.com/analytics/v2.4/management/accounts/876543/webproperties" />
+        <dxp:property name="ga:accountId" value="876543" />
+        <dxp:property name="ga:accountName" value="foobarbaz" />
+    </entry>
+    <entry gd:kind="analytics#account">
+        <id>https://www.googleapis.com/analytics/v2.4/management/accounts/23456789</id>
+        <updated>2011-05-17T06:53:24.385Z</updated>
+        <title type="text">Google Analytics Account brain dump</title>
+        <link rel="self" type="application/atom+xml" href="https://www.googleapis.com/analytics/v2.4/management/accounts/23456789" />
+        <link rel="http://schemas.google.com/ga/2009#child" type="application/atom+xml" gd:targetKind="analytics#webproperties" href="https://www.googleapis.com/analytics/v2.4/management/accounts/23456789/webproperties" />
+        <dxp:property name="ga:accountId" value="23456789" />
+        <dxp:property name="ga:accountName" value="brain dump" />
+    </entry>
+</feed>

+ 76 - 79
tests/Zend/Gdata/Analytics/_files/TestDataFeed.xml

@@ -1,79 +1,76 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<feed xmlns='http://www.w3.org/2005/Atom' xmlns:dxp='http://schemas.google.com/analytics/2009' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;DUINSHcycSp7I2A9WxRWFEQ.&quot;' gd:kind='analytics#data'>
-        <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&amp;dimensions=ga:medium,ga:source&amp;metrics=ga:bounces,ga:visits&amp;filters=ga:medium%3D%3Dreferral&amp;start-date=2008-10-01&amp;end-date=2008-10-31</id>
-        <updated>2008-10-31T16:59:59.999-07:00</updated>
-        <title>Google Analytics Data for Profile 1174</title>
-        <link rel='self' type='application/atom+xml' href='http://www.google.com/analytics/feeds/data?max-results=5&amp;sort=-ga%3Avisits&amp;end-date=2008-10-31&amp;start-date=2008-10-01&amp;metrics=ga%3Avisits%2Cga%3Abounces&amp;ids=ga%3A1174&amp;dimensions=ga%3Asource%2Cga%3Amedium&amp;filters=ga%3Amedium%3D%3Dreferral'/>
-        <link rel='next' type='application/atom+xml' href='http://www.google.com/analytics/feeds/data?start-index=6&amp;max-results=5&amp;sort=-ga%3Avisits&amp;end-date=2008-10-31&amp;start-date=2008-10-01&amp;metrics=ga%3Avisits%2Cga%3Abounces&amp;ids=ga%3A1174&amp;dimensions=ga%3Asource%2Cga%3Amedium&amp;filters=ga%3Amedium%3D%3Dreferral'/>
-        <author>
-                <name>Google Analytics</name>
-        </author>
-        <generator version='1.0'>Google Analytics</generator>
-        <openSearch:totalResults>6451</openSearch:totalResults>
-        <openSearch:startIndex>1</openSearch:startIndex>
-        <openSearch:itemsPerPage>5</openSearch:itemsPerPage>
-        <dxp:aggregates>
-                <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='136540'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='101535'/>
-        </dxp:aggregates>
-        <dxp:containsSampledData>false</dxp:containsSampledData>
-        <dxp:dataSource>
-                <dxp:property name='ga:profileId' value='1174'/>
-                <dxp:property name='ga:webPropertyId' value='UA-30481-1'/>
-                <dxp:property name='ga:accountName' value='Google Store'/>
-                <dxp:tableId>ga:1174</dxp:tableId>
-                <dxp:tableName>www.googlestore.com</dxp:tableName>
-        </dxp:dataSource>
-        <dxp:endDate>2008-10-31</dxp:endDate>
-        <dxp:startDate>2008-10-01</dxp:startDate>
-        <entry gd:etag='W/&quot;C0UEQX47eSp7I2A9WxRWFEw.&quot;' gd:kind='analytics#datarow'>
-                <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&amp;ga:medium=referral&amp;ga:source=blogger.com&amp;filters=ga:medium%3D%3Dreferral&amp;start-date=2008-10-01&amp;end-date=2008-10-31</id>
-                <updated>2008-10-30T17:00:00.001-07:00</updated>
-                <title>ga:source=blogger.com | ga:medium=referral</title>
-                <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/>
-                <dxp:dimension name='ga:source' value='blogger.com'/>
-                <dxp:dimension name='ga:medium' value='referral'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='68140'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='61095'/>
-        </entry>
-        <entry gd:etag='W/&quot;C0UEQX47eSp7I2A9WxRWFEw.&quot;' gd:kind='analytics#datarow'>
-                <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&amp;ga:medium=referral&amp;ga:source=google.com&amp;filters=ga:medium%3D%3Dreferral&amp;start-date=2008-10-01&amp;end-date=2008-10-31</id>
-                <updated>2008-10-30T17:00:00.001-07:00</updated>
-                <title>ga:source=google.com | ga:medium=referral</title>
-                <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/>
-                <dxp:dimension name='ga:source' value='google.com'/>
-                <dxp:dimension name='ga:medium' value='referral'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='29666'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='14979'/>
-        </entry>
-        <entry gd:etag='W/&quot;C0UEQX47eSp7I2A9WxRWFEw.&quot;' gd:kind='analytics#datarow'>
-                <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&amp;ga:medium=referral&amp;ga:source=stumbleupon.com&amp;filters=ga:medium%3D%3Dreferral&amp;start-date=2008-10-01&amp;end-date=2008-10-31</id>
-                <updated>2008-10-30T17:00:00.001-07:00</updated>
-                <title>ga:source=stumbleupon.com | ga:medium=referral</title>
-                <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/>
-                <dxp:dimension name='ga:source' value='stumbleupon.com'/>
-                <dxp:dimension name='ga:medium' value='referral'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='4012'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='848'/>
-        </entry>
-        <entry gd:etag='W/&quot;C0UEQX47eSp7I2A9WxRWFEw.&quot;' gd:kind='analytics#datarow'>
-                <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&amp;ga:medium=referral&amp;ga:source=google.co.uk&amp;filters=ga:medium%3D%3Dreferral&amp;start-date=2008-10-01&amp;end-date=2008-10-31</id>
-                <updated>2008-10-30T17:00:00.001-07:00</updated>
-                <title>ga:source=google.co.uk | ga:medium=referral</title>
-                <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/>
-                <dxp:dimension name='ga:source' value='google.co.uk'/>
-                <dxp:dimension name='ga:medium' value='referral'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='2968'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='2084'/>
-        </entry>
-        <entry gd:etag='W/&quot;C0UEQX47eSp7I2A9WxRWFEw.&quot;' gd:kind='analytics#datarow'>
-                <id>http://www.google.com/analytics/feeds/data?ids=ga:1174&amp;ga:medium=referral&amp;ga:source=google.co.in&amp;filters=ga:medium%3D%3Dreferral&amp;start-date=2008-10-01&amp;end-date=2008-10-31</id>
-                <updated>2008-10-30T17:00:00.001-07:00</updated>
-                <title>ga:source=google.co.in | ga:medium=referral</title>
-                <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/>
-                <dxp:dimension name='ga:source' value='google.co.in'/>
-                <dxp:dimension name='ga:medium' value='referral'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:visits' type='integer' value='2793'/>
-                <dxp:metric confidenceInterval='0.0' name='ga:bounces' type='integer' value='1891'/>
-        </entry>
-</feed>
+<?xml version="1.0" encoding="UTF-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dxp="http://schemas.google.com/analytics/2009" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">
+    <id>https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&amp;dimensions=ga:medium,ga:source,ga:browserVersion,ga:month&amp;metrics=ga:bounces,ga:visits&amp;sort=-ga:visits,ga:bounces&amp;filters=ga:browser%3D%3DFirefox&amp;start-date=2011-05-01&amp;end-date=2011-05-31&amp;start-index=1&amp;max-results=50</id>
+    <updated>2012-07-13T17:05:16.454Z</updated>
+    <title type="text">Google Analytics Data for Profile 45678912</title>
+    <link rel="self" type="application/atom+xml" href="https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&amp;dimensions=ga:medium,ga:source,ga:browserVersion,ga:month&amp;metrics=ga:bounces,ga:visits&amp;sort=-ga:visits,ga:bounces&amp;filters=ga:browser%3D%3DFirefox&amp;start-date=2011-05-01&amp;end-date=2011-05-31&amp;start-index=1&amp;max-results=50" />
+    <author>
+        <name>Google Analytics</name>
+    </author>
+    <generator>Google Analytics</generator>
+    <openSearch:totalResults>4</openSearch:totalResults>
+    <openSearch:startIndex>1</openSearch:startIndex>
+    <openSearch:itemsPerPage>50</openSearch:itemsPerPage>
+    <dxp:aggregates>
+        <dxp:metric name="ga:bounces" type="integer" value="9" />
+        <dxp:metric name="ga:visits" type="integer" value="20" />
+    </dxp:aggregates>
+    <dxp:containsSampledData>false</dxp:containsSampledData>
+    <dxp:dataSource>
+        <dxp:property name="ga:profileId" value="45678912" />
+        <dxp:property name="ga:webPropertyId" value="UA-23456789-1" />
+        <dxp:property name="ga:accountName" value="foobar" />
+        <dxp:tableId>ga:45678912</dxp:tableId>
+        <dxp:tableName>www.foobar.de</dxp:tableName>
+    </dxp:dataSource>
+    <dxp:endDate>2011-05-31</dxp:endDate>
+    <dxp:startDate>2011-05-01</dxp:startDate>
+    <entry>
+        <id>https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&amp;ga:browserVersion=4.0.1&amp;ga:medium=referral&amp;ga:month=05&amp;ga:source=foobarbaz.de&amp;filters=ga:browser%3D%3DFirefox&amp;start-date=2011-05-01&amp;end-date=2011-05-31</id>
+        <updated>2012-07-13T17:05:16.454Z</updated>
+        <title type="text">ga:medium=referral | ga:source=foobarbaz.de | ga:browserVersion=4.0.1 | ga:month=05</title>
+        <link rel="alternate" type="text/html" href="http://www.google.com/analytics" />
+        <dxp:dimension name="ga:medium" value="referral" />
+        <dxp:dimension name="ga:source" value="foobarbaz.de" />
+        <dxp:dimension name="ga:browserVersion" value="4.0.1" />
+        <dxp:dimension name="ga:month" value="05" />
+        <dxp:metric name="ga:bounces" type="integer" value="5" />
+        <dxp:metric name="ga:visits" type="integer" value="12" />
+    </entry>
+    <entry>
+        <id>https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&amp;ga:browserVersion=3.6.17&amp;ga:medium=referral&amp;ga:month=05&amp;ga:source=foobarbaz.de&amp;filters=ga:browser%3D%3DFirefox&amp;start-date=2011-05-01&amp;end-date=2011-05-31</id>
+        <updated>2012-07-13T17:05:16.454Z</updated>
+        <title type="text">ga:medium=referral | ga:source=foobar.de | ga:browserVersion=3.6.17 | ga:month=05</title>
+        <link rel="alternate" type="text/html" href="http://www.google.com/analytics" />
+        <dxp:dimension name="ga:medium" value="referral" />
+        <dxp:dimension name="ga:source" value="foobar.de" />
+        <dxp:dimension name="ga:browserVersion" value="3.6.17" />
+        <dxp:dimension name="ga:month" value="05" />
+        <dxp:metric name="ga:bounces" type="integer" value="1" />
+        <dxp:metric name="ga:visits" type="integer" value="3" />
+    </entry>
+    <entry>
+        <id>https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&amp;ga:browserVersion=3.5.19&amp;ga:medium=referral&amp;ga:month=05&amp;ga:source=foobarbaz.ch&amp;filters=ga:browser%3D%3DFirefox&amp;start-date=2011-05-01&amp;end-date=2011-05-31</id>
+        <updated>2012-07-13T17:05:16.454Z</updated>
+        <title type="text">ga:medium=referral | ga:source=foobarbaz.ch | ga:browserVersion=3.5.19 | ga:month=05</title>
+        <link rel="alternate" type="text/html" href="http://www.google.com/analytics" />
+        <dxp:dimension name="ga:medium" value="referral" />
+        <dxp:dimension name="ga:source" value="foobarbaz.ch" />
+        <dxp:dimension name="ga:browserVersion" value="3.5.19" />
+        <dxp:dimension name="ga:month" value="05" />
+        <dxp:metric name="ga:bounces" type="integer" value="1" />
+        <dxp:metric name="ga:visits" type="integer" value="1" />
+    </entry>
+    <entry>
+        <id>https://www.googleapis.com/analytics/v2.4/data?ids=ga:45678912&amp;ga:browserVersion=3.6.17&amp;ga:medium=referral&amp;ga:month=05&amp;ga:source=foobarbaz.ch&amp;filters=ga:browser%3D%3DFirefox&amp;start-date=2011-05-01&amp;end-date=2011-05-31</id>
+        <updated>2012-07-13T17:05:16.454Z</updated>
+        <title type="text">ga:medium=referral | ga:source=baz.ch | ga:browserVersion=3.6.17 | ga:month=05</title>
+        <link rel="alternate" type="text/html" href="http://www.google.com/analytics" />
+        <dxp:dimension name="ga:medium" value="referral" />
+        <dxp:dimension name="ga:source" value="baz.ch" />
+        <dxp:dimension name="ga:browserVersion" value="3.6.17" />
+        <dxp:dimension name="ga:month" value="05" />
+        <dxp:metric name="ga:bounces" type="integer" value="1" />
+        <dxp:metric name="ga:visits" type="integer" value="1" />
+    </entry>
+</feed>