Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a datapoint object. Also, data pulling "appears" to work, but I…

…'m not getting any data back from GA in my tests. I won't have time to work on fixing that until later today.
  • Loading branch information...
commit f5aa20b7a561f72d4fb4839ff3bb1c009c007d53 1 parent 90dc8c5
Clinton Ecker authored
View
8 src/googleanalytics/account.py
@@ -141,8 +141,12 @@ def get_data(self, start_date, end_date, dimensions=[], metrics=[], sort=[], fil
data = urllib.urlencode(data)
response = self.connection.make_request('GET', path=path, data=data)
- #print response.read()
-
+ raw_xml = response.read()
+ print raw_xml
+ xml_tree = self.connection.parse_response(raw_xml)
+ data_rows = xml_tree.getiterator('{http://www.w3.org/2005/Atom}entry')
+ return data_rows
+
def process_filters(self, filters):
processed_filters = []
multiple_filters = False
View
12 src/googleanalytics/data.py
@@ -0,0 +1,12 @@
+class DataPoint:
+ """docstring for DataPoint"""
+
+ def __init__(self, account=None, connection=None, title=None, dimensions=[], metrics=[]):
+ self.account = account
+ self.connection = connection
+ self.title = title
+ self.dimensions = dimensions
+ self.metrics = metrics
+
+ def __repr__(self):
+ return '<DataPoint: %s / %s>' % (self.account.title, self.title)
View
18 src/googleanalytics/tests.py
@@ -42,8 +42,22 @@ def test_basic_get_data(self):
for c in range(len(valid_profile_ids)):
account = connection.get_account(valid_profile_ids[c])
- account.get_data(start_date=start_date, end_date=end_date)
-
+ data = account.get_data(start_date=start_date, end_date=end_date)
+ assert len(data) > 0
+
+ def test_dimensions_get_data(self):
+ Connection = googleanalytics.Connection
+ connection = Connection()
+ valid_profile_ids = config.get_valid_profiles()
+
+ start_date = datetime.date(2009, 02, 20)
+ end_date = datetime.date(2009, 02, 21)
+
+ for c in range(len(valid_profile_ids)):
+ account = connection.get_account(valid_profile_ids[c])
+ data = account.get_data(start_date=start_date, end_date=end_date, dimensions=['browser', 'country'])
+ assert len(data) > 0
+
def test_basic_filter(self):
filters = [
['country', '==', 'United States'],
Please sign in to comment.
Something went wrong with that request. Please try again.