Skip to content

Commit 5588527

Browse files
committed
Committing latest changes.
1 parent 859d8ee commit 5588527

File tree

117 files changed

+12545
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+12545
-45
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
12.1.0 -- 06/06/18
2+
* Added support and examples for AdWords v201806.
3+
* Resolved issues:
4+
- Issue 282: https://github.com/googleads/googleads-python-lib/issues/282
5+
- Issue 288: https://github.com/googleads/googleads-python-lib/issues/288
6+
17
12.0.0 -- 05/15/18
28
* Added support and examples for DFP v201805.
39
* Removed support for DFP v201705.

examples/adwords/v201710/remarketing/add_conversion_tracker.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ def main(client):
4141
'xsi_type': 'AdWordsConversionTracker',
4242
'name': 'Mars cruise customers #%s' % uuid.uuid4(),
4343
'category': 'DEFAULT',
44-
'textFormat': 'HIDDEN',
4544
# Optional fields.
4645
'status': 'ENABLED',
4746
'viewthroughLookbackWindow': '15',
48-
'conversionPageLanguage': 'en',
49-
'backgroundColor': '#0000FF',
5047
'defaultRevenueValue': '23.41',
5148
'alwaysUseDefaultRevenueValue': 'true'
5249
}
@@ -57,10 +54,9 @@ def main(client):
5754
# Display results.
5855
for conversion_tracker in conversion_trackers['value']:
5956
print ('Conversion tracker with id "%s", name "%s", status "%s" '
60-
'and category "%s" and snippet \n"%s"\n was added.\n' %
57+
'and category "%s" \n was added.\n' %
6158
(conversion_tracker['id'], conversion_tracker['name'],
62-
conversion_tracker['status'], conversion_tracker['category'],
63-
conversion_tracker['snippet']))
59+
conversion_tracker['status'], conversion_tracker['category']))
6460

6561

6662
if __name__ == '__main__':

examples/adwords/v201802/remarketing/add_conversion_tracker.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ def main(client):
4141
'xsi_type': 'AdWordsConversionTracker',
4242
'name': 'Mars cruise customers #%s' % uuid.uuid4(),
4343
'category': 'DEFAULT',
44-
'textFormat': 'HIDDEN',
4544
# Optional fields.
4645
'status': 'ENABLED',
4746
'viewthroughLookbackWindow': '15',
48-
'conversionPageLanguage': 'en',
49-
'backgroundColor': '#0000FF',
5047
'defaultRevenueValue': '23.41',
5148
'alwaysUseDefaultRevenueValue': 'true'
5249
}
@@ -57,10 +54,9 @@ def main(client):
5754
# Display results.
5855
for conversion_tracker in conversion_trackers['value']:
5956
print ('Conversion tracker with id "%s", name "%s", status "%s" '
60-
'and category "%s" and snippet \n"%s"\n was added.\n' %
57+
'and category "%s"\n was added.\n' %
6158
(conversion_tracker['id'], conversion_tracker['name'],
62-
conversion_tracker['status'], conversion_tracker['category'],
63-
conversion_tracker['snippet']))
59+
conversion_tracker['status'], conversion_tracker['category']))
6460

6561

6662
if __name__ == '__main__':
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2016 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Examples for AdWords."""
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2016 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Account management examples."""
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2016 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This example accepts a pending Google Merchant Center invitation link.
18+
19+
The LoadFromStorage method is pulling credentials and properties from a
20+
"googleads.yaml" file. By default, it looks for this file in your home
21+
directory. For more information, see the "Caching authentication information"
22+
section of our README.
23+
24+
"""
25+
26+
27+
from googleads import adwords
28+
29+
30+
SERVICE_LINK_ID = 'INSERT_SERVICE_LINK_ID_HERE'
31+
32+
33+
def main(client, service_link_id):
34+
# Initialize appropriate service.
35+
customer_service = client.GetService(
36+
'CustomerService', version='v201806')
37+
38+
# Create the operation to set the status to ACTIVE.
39+
operations = [{
40+
'operator': 'SET',
41+
'operand': {
42+
'serviceLinkId': service_link_id,
43+
'serviceType': 'MERCHANT_CENTER',
44+
'linkStatus': 'ACTIVE',
45+
}
46+
}]
47+
48+
# Update the service link.
49+
mutated_service_links = customer_service.mutateServiceLinks(operations)
50+
51+
# Display results.
52+
for mutated_service_link in mutated_service_links:
53+
print ('Service link with service link ID "%s", type "%s" was updated '
54+
'to status: "%s".' % (mutated_service_link['serviceLinkId'],
55+
mutated_service_link['serviceType'],
56+
mutated_service_link['linkStatus']))
57+
58+
59+
if __name__ == '__main__':
60+
# Initialize client object.
61+
adwords_client = adwords.AdWordsClient.LoadFromStorage()
62+
main(adwords_client, SERVICE_LINK_ID)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2016 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This example illustrates how to create an account.
18+
19+
Note by default this account will only be accessible via its parent AdWords
20+
manager account..
21+
22+
The LoadFromStorage method is pulling credentials and properties from a
23+
"googleads.yaml" file. By default, it looks for this file in your home
24+
directory. For more information, see the "Caching authentication information"
25+
section of our README.
26+
27+
"""
28+
29+
30+
from datetime import datetime
31+
from googleads import adwords
32+
33+
34+
def main(client):
35+
# Initialize appropriate service.
36+
managed_customer_service = client.GetService(
37+
'ManagedCustomerService', version='v201806')
38+
39+
today = datetime.today().strftime('%Y%m%d %H:%M:%S')
40+
# Construct operations and add campaign.
41+
operations = [{
42+
'operator': 'ADD',
43+
'operand': {
44+
'name': 'Account created with ManagedCustomerService on %s' % today,
45+
'currencyCode': 'EUR',
46+
'dateTimeZone': 'Europe/London',
47+
},
48+
# For whitelisted users only, uncomment the inviteeEmail and inviteeRole
49+
# attributes to invite a user to have access to an account on an ADD. An
50+
# email will be sent inviting the user to have access to the newly created
51+
# account.
52+
# 'inviteeEmail': '[email protected]',
53+
# 'inviteeRole': 'ADMINISTRATIVE'
54+
}]
55+
56+
# Create the account. It is possible to create multiple accounts with one
57+
# request by sending an array of operations.
58+
accounts = managed_customer_service.mutate(operations)
59+
60+
# Display results.
61+
for account in accounts['value']:
62+
print ('Account with customer ID "%s" was successfully created.'
63+
% account['customerId'])
64+
65+
66+
if __name__ == '__main__':
67+
# Initialize client object.
68+
adwords_client = adwords.AdWordsClient.LoadFromStorage()
69+
main(adwords_client)
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2016 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This example gets the changes in the account during the last 24 hours.
18+
19+
The LoadFromStorage method is pulling credentials and properties from a
20+
"googleads.yaml" file. By default, it looks for this file in your home
21+
directory. For more information, see the "Caching authentication information"
22+
section of our README.
23+
24+
"""
25+
26+
27+
import datetime
28+
from googleads import adwords
29+
30+
31+
def main(client):
32+
# Initialize appropriate service.
33+
customer_sync_service = client.GetService(
34+
'CustomerSyncService', version='v201806')
35+
campaign_service = client.GetService('CampaignService', version='v201806')
36+
37+
# Construct selector and get all campaigns.
38+
selector = {
39+
'fields': ['Id', 'Name', 'Status']
40+
}
41+
campaigns = campaign_service.get(selector)
42+
campaign_ids = []
43+
if 'entries' in campaigns:
44+
for campaign in campaigns['entries']:
45+
campaign_ids.append(campaign['id'])
46+
else:
47+
print 'No campaigns were found.'
48+
return
49+
50+
# Construct selector and get all changes.
51+
today = datetime.datetime.today()
52+
yesterday = today - datetime.timedelta(1)
53+
selector = {
54+
'dateTimeRange': {
55+
'min': yesterday.strftime('%Y%m%d %H%M%S'),
56+
'max': today.strftime('%Y%m%d %H%M%S')
57+
},
58+
'campaignIds': campaign_ids
59+
}
60+
account_changes = customer_sync_service.get(selector)
61+
62+
# Display results.
63+
if account_changes:
64+
if 'lastChangeTimestamp' in account_changes:
65+
print 'Most recent changes: %s' % account_changes['lastChangeTimestamp']
66+
if account_changes['changedCampaigns']:
67+
for data in account_changes['changedCampaigns']:
68+
print ('Campaign with id "%s" has change status "%s".'
69+
% (data['campaignId'], data['campaignChangeStatus']))
70+
if (data['campaignChangeStatus'] != 'NEW' and
71+
data['campaignChangeStatus'] != 'FIELDS_UNCHANGED'):
72+
if 'addedCampaignCriteria' in data:
73+
print (' Added campaign criteria: %s' %
74+
data['addedCampaignCriteria'])
75+
if 'removedCampaignCriteria' in data:
76+
print (' Removed campaign criteria: %s' %
77+
data['removedCampaignCriteria'])
78+
if 'changedAdGroups' in data:
79+
for ad_group_data in data['changedAdGroups']:
80+
print (' Ad group with id "%s" has change status "%s".'
81+
% (ad_group_data['adGroupId'],
82+
ad_group_data['adGroupChangeStatus']))
83+
if ad_group_data['adGroupChangeStatus'] != 'NEW':
84+
if 'changedAds' in ad_group_data:
85+
print ' Changed ads: %s' % ad_group_data['changedAds']
86+
if 'changedCriteria' in ad_group_data:
87+
print (' Changed criteria: %s' %
88+
ad_group_data['changedCriteria'])
89+
if 'removedCriteria' in ad_group_data:
90+
print (' Removed criteria: %s' %
91+
ad_group_data['removedCriteria'])
92+
else:
93+
print 'No changes were found.'
94+
95+
96+
if __name__ == '__main__':
97+
# Initialize client object.
98+
adwords_client = adwords.AdWordsClient.LoadFromStorage()
99+
main(adwords_client)

0 commit comments

Comments
 (0)