Update AdExchange Buyer API examples to version v1.2.
Fixes issue #248.
diff --git a/samples/adexchangebuyer/get_creative.py b/samples/adexchangebuyer/get_creative.py
index e2b2da9..ffa3385 100644
--- a/samples/adexchangebuyer/get_creative.py
+++ b/samples/adexchangebuyer/get_creative.py
@@ -19,7 +19,8 @@
Tags: creatives.insert
"""
-__author__ = 'david.t@google.com (David Torres)'
+__author__ = ('david.t@google.com (David Torres)',
+ 'jdilallo@google.com (Joseph DiLallo)')
import pprint
import sys
@@ -32,11 +33,6 @@
'The ID of the account that contains the creative',
short_name='a')
gflags.MarkFlagAsRequired('account_id')
-gflags.DEFINE_string('adgroup_id', None,
- 'The pretargeting adgroup id to which the creative is '
- 'associated with',
- short_name='g')
-gflags.MarkFlagAsRequired('adgroup_id')
gflags.DEFINE_string('buyer_creative_id', None,
'A buyer-specific id that identifies this creative',
short_name='c')
@@ -46,7 +42,6 @@
def main(argv):
sample_utils.process_flags(argv)
account_id = gflags.FLAGS.account_id
- adgroup_id = gflags.FLAGS.adgroup_id
buyer_creative_id = gflags.FLAGS.buyer_creative_id
pretty_printer = pprint.PrettyPrinter()
@@ -56,7 +51,6 @@
try:
# Construct the request.
request = service.creatives().get(accountId=account_id,
- adgroupId=adgroup_id,
buyerCreativeId=buyer_creative_id)
# Execute request and print response.
diff --git a/samples/adexchangebuyer/sample_utils.py b/samples/adexchangebuyer/sample_utils.py
index 89f95ff..7083efa 100644
--- a/samples/adexchangebuyer/sample_utils.py
+++ b/samples/adexchangebuyer/sample_utils.py
@@ -108,5 +108,5 @@
http = credentials.authorize(http)
# Construct a service object via the discovery service.
- service = build('adexchangebuyer', 'v1', http=http)
+ service = build('adexchangebuyer', 'v1.2', http=http)
return service
diff --git a/samples/adexchangebuyer/submit_creative.py b/samples/adexchangebuyer/submit_creative.py
index 1052eae..abba2e3 100644
--- a/samples/adexchangebuyer/submit_creative.py
+++ b/samples/adexchangebuyer/submit_creative.py
@@ -19,7 +19,8 @@
Tags: creatives.insert
"""
-__author__ = 'david.t@google.com (David Torres)'
+__author__ = ('david.t@google.com (David Torres)',
+ 'jdilallo@google.com (Joseph DiLallo)')
import pprint
import sys
@@ -32,22 +33,20 @@
'The ID of the account to which submit the creative',
short_name='a')
gflags.MarkFlagAsRequired('account_id')
-gflags.DEFINE_string('adgroup_id', None,
- 'The pretargeting adgroup id that this creative will be '
- 'associated with',
- short_name='g')
-gflags.MarkFlagAsRequired('adgroup_id')
gflags.DEFINE_string('buyer_creative_id', None,
'A buyer-specific id identifying the creative in this ad',
short_name='c')
gflags.MarkFlagAsRequired('buyer_creative_id')
+gflags.DEFINE_string('agency_id', None,
+ 'The id of the agency who created this ad',
+ short_name='g')
def main(argv):
sample_utils.process_flags(argv)
account_id = gflags.FLAGS.account_id
- adgroup_id = gflags.FLAGS.adgroup_id
buyer_creative_id = gflags.FLAGS.buyer_creative_id
+ agency_id = gflags.FLAGS.agency_id
pretty_printer = pprint.PrettyPrinter()
# Authenticate and construct service.
@@ -57,7 +56,6 @@
# Create a new creative to submit.
creative_body = {
'accountId': account_id,
- 'adgroupId': adgroup_id,
'buyerCreativeId': buyer_creative_id,
'HTMLSnippet': ('<html><body><a href="http://www.google.com">'
'Hi there!</a></body></html>'),
@@ -66,6 +64,8 @@
'height': 250,
'advertiserName': 'google'
}
+ if agency_id:
+ creative_body['agencyId'] = agency_id
creative = service.creatives().insert(body=creative_body).execute()
# Print the response. If the creative has been already reviewed, its status
# and categories will be included in the response.