Skip to content

Commit 731680a

Browse files
committed
Update AdExchange Buyer API examples to version v1.2.
Fixes issue googleapis#248.
1 parent 73c9a44 commit 731680a

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

samples/adexchangebuyer/get_creative.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
Tags: creatives.insert
2020
"""
2121

22-
__author__ = 'david.t@google.com (David Torres)'
22+
__author__ = ('david.t@google.com (David Torres)',
23+
'jdilallo@google.com (Joseph DiLallo)')
2324

2425
import pprint
2526
import sys
@@ -32,11 +33,6 @@
3233
'The ID of the account that contains the creative',
3334
short_name='a')
3435
gflags.MarkFlagAsRequired('account_id')
35-
gflags.DEFINE_string('adgroup_id', None,
36-
'The pretargeting adgroup id to which the creative is '
37-
'associated with',
38-
short_name='g')
39-
gflags.MarkFlagAsRequired('adgroup_id')
4036
gflags.DEFINE_string('buyer_creative_id', None,
4137
'A buyer-specific id that identifies this creative',
4238
short_name='c')
@@ -46,7 +42,6 @@
4642
def main(argv):
4743
sample_utils.process_flags(argv)
4844
account_id = gflags.FLAGS.account_id
49-
adgroup_id = gflags.FLAGS.adgroup_id
5045
buyer_creative_id = gflags.FLAGS.buyer_creative_id
5146
pretty_printer = pprint.PrettyPrinter()
5247

@@ -56,7 +51,6 @@ def main(argv):
5651
try:
5752
# Construct the request.
5853
request = service.creatives().get(accountId=account_id,
59-
adgroupId=adgroup_id,
6054
buyerCreativeId=buyer_creative_id)
6155

6256
# Execute request and print response.

samples/adexchangebuyer/sample_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ def initialize_service():
108108
http = credentials.authorize(http)
109109

110110
# Construct a service object via the discovery service.
111-
service = build('adexchangebuyer', 'v1', http=http)
111+
service = build('adexchangebuyer', 'v1.2', http=http)
112112
return service

samples/adexchangebuyer/submit_creative.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
Tags: creatives.insert
2020
"""
2121

22-
__author__ = 'david.t@google.com (David Torres)'
22+
__author__ = ('david.t@google.com (David Torres)',
23+
'jdilallo@google.com (Joseph DiLallo)')
2324

2425
import pprint
2526
import sys
@@ -32,22 +33,20 @@
3233
'The ID of the account to which submit the creative',
3334
short_name='a')
3435
gflags.MarkFlagAsRequired('account_id')
35-
gflags.DEFINE_string('adgroup_id', None,
36-
'The pretargeting adgroup id that this creative will be '
37-
'associated with',
38-
short_name='g')
39-
gflags.MarkFlagAsRequired('adgroup_id')
4036
gflags.DEFINE_string('buyer_creative_id', None,
4137
'A buyer-specific id identifying the creative in this ad',
4238
short_name='c')
4339
gflags.MarkFlagAsRequired('buyer_creative_id')
40+
gflags.DEFINE_string('agency_id', None,
41+
'The id of the agency who created this ad',
42+
short_name='g')
4443

4544

4645
def main(argv):
4746
sample_utils.process_flags(argv)
4847
account_id = gflags.FLAGS.account_id
49-
adgroup_id = gflags.FLAGS.adgroup_id
5048
buyer_creative_id = gflags.FLAGS.buyer_creative_id
49+
agency_id = gflags.FLAGS.agency_id
5150
pretty_printer = pprint.PrettyPrinter()
5251

5352
# Authenticate and construct service.
@@ -57,7 +56,6 @@ def main(argv):
5756
# Create a new creative to submit.
5857
creative_body = {
5958
'accountId': account_id,
60-
'adgroupId': adgroup_id,
6159
'buyerCreativeId': buyer_creative_id,
6260
'HTMLSnippet': ('<html><body><a href="http://www.google.com">'
6361
'Hi there!</a></body></html>'),
@@ -66,6 +64,8 @@ def main(argv):
6664
'height': 250,
6765
'advertiserName': 'google'
6866
}
67+
if agency_id:
68+
creative_body['agencyId'] = agency_id
6969
creative = service.creatives().insert(body=creative_body).execute()
7070
# Print the response. If the creative has been already reviewed, its status
7171
# and categories will be included in the response.

0 commit comments

Comments
 (0)