Skip to content

Commit fb4f182

Browse files
committed
Dowload currency information for each account
1 parent 2604dc7 commit fb4f182

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.7.0
4+
*2018-03-12*
5+
- Download currency information for each account
6+
7+
38
## 1.6.1
49
*2018-03-05*
510
- Made API version configurable

adwords_downloader/downloader.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import csv
21
import datetime
32
import errno
43
import gzip
54
import http
6-
import json
75
import csv
86
import logging
97
import re
@@ -56,7 +54,7 @@ def _fetch_managed_customer_page(self):
5654
5755
"""
5856
service = self.GetService(service_name='ManagedCustomerService')
59-
return service.get({'fields': ['CustomerId', 'Name', 'CanManageClients', 'AccountLabels']})
57+
return service.get({'fields': ['CustomerId', 'Name', 'CanManageClients', 'AccountLabels', 'CurrencyCode']})
6058

6159
def _fetch_client_customers(self):
6260
"""Fetches the client customers, including their names and account labels, from
@@ -78,7 +76,8 @@ def _fetch_client_customers(self):
7876
account_labels = [x.name for x in managed_customer.accountLabels]
7977
client_customers[managed_customer.customerId] = {
8078
'Name': managed_customer.name,
81-
'Labels': account_labels}
79+
'Labels': account_labels,
80+
'Currency Code': managed_customer.currencyCode}
8281
return client_customers
8382

8483

@@ -209,7 +208,7 @@ def download_account_structure(api_client: AdWordsApiClient):
209208
tmp_filepath = Path(tmp_dir, filename)
210209
with gzip.open(str(tmp_filepath), 'wt') as tmp_campaign_structure_file:
211210
header = ['Ad Id', 'Ad', 'Ad Group Id', 'Ad Group', 'Campaign Id',
212-
'Campaign', 'Customer Id', 'Customer Name', 'Attributes']
211+
'Campaign', 'Customer Id', 'Customer Name', 'Attributes', 'Currency Code']
213212
writer = csv.writer(tmp_campaign_structure_file, delimiter="\t")
214213
writer.writerow(header)
215214
for client_customer_id, client_customer in api_client.client_customers.items():
@@ -224,7 +223,7 @@ def download_account_structure(api_client: AdWordsApiClient):
224223
for ad_id, ad_data_dict in ad_data.items():
225224
campaign_id = ad_data_dict['Campaign ID']
226225
ad_group_id = ad_data_dict['Ad group ID']
227-
226+
currency_code = client_customer['Currency Code']
228227
attributes = {**client_customer_attributes,
229228
**campaign_attributes.get(campaign_id, {}),
230229
**ad_group_attributes.get(ad_group_id, {}),
@@ -238,7 +237,9 @@ def download_account_structure(api_client: AdWordsApiClient):
238237
ad_data_dict['Campaign'],
239238
str(client_customer_id),
240239
client_customer_name,
241-
json.dumps(attributes)]
240+
json.dumps(attributes),
241+
currency_code
242+
]
242243

243244
writer.writerow(ad)
244245

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='google-adwords-performance-downloader',
5-
version='1.6.1',
5+
version='1.7.0',
66

77
description="Downloads data from the Google Adwords Api to local files",
88

0 commit comments

Comments
 (0)