Skip to content

Commit 6a0994d

Browse files
Tom Osowskijuanshishidotushdante
authored
Update SDK for Ads API v10 (#288)
* [v10] Tracking Tags and minor field changes (#286) * Update Cards to switch to ios_app_store_identifier and deprecate ipad params (#284) * Ads API v10 (#283) * Add store identifiers to line item * updated audience_summary to audience_estimate * removed automatically_select_bid from line items * update to v10 Co-authored-by: Tom Osowski <[email protected]> * Update python-package.yml (#290) (#291) Co-authored-by: Juan Shishido <[email protected]> Co-authored-by: Tushar Bhushan <[email protected]>
1 parent 75b397a commit 6a0994d

11 files changed

+47
-51
lines changed

examples/audience_summary.py renamed to examples/audience_estimate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from twitter_ads.client import Client
2-
from twitter_ads.targeting import AudienceSummary
2+
from twitter_ads.targeting import AudienceEstimate
33

44
CONSUMER_KEY = 'your consumer key'
55
CONSUMER_SECRET = 'your consumer secret'
@@ -35,6 +35,6 @@
3535
]
3636
}
3737

38-
audience_summary = AudienceSummary.load(account=account, params=params)
38+
audience_estimate = AudienceEstimate.load(account=account, params=params)
3939

40-
print (audience_summary.audience_size)
40+
print (audience_estimate.audience_size)

tests/fixtures/accounts_all.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"timezone_switch_at": "2014-11-17T08:00:00Z",
1010
"id": "2iqph",
1111
"created_at": "2015-03-04T10:50:42Z",
12-
"salt": "5ab2pizq7qxjjqrx3z67f4wbko61o7xs",
1312
"updated_at": "2015-04-11T05:20:08Z",
1413
"approval_status": "ACCEPTED",
1514
"deleted": false
@@ -20,7 +19,6 @@
2019
"timezone_switch_at": "2014-11-17T08:00:00Z",
2120
"id": "pz6ec",
2221
"created_at": "2015-05-29T00:52:16Z",
23-
"salt": "39ku32xvhdt0jax8thps2c70e2fv3yok",
2422
"updated_at": "2015-05-29T00:52:16Z",
2523
"approval_status": "ACCEPTED",
2624
"deleted": false
@@ -31,7 +29,6 @@
3129
"timezone_switch_at": "2014-11-17T08:00:00Z",
3230
"id": "j9ozo",
3331
"created_at": "2015-05-01T12:08:10Z",
34-
"salt": "winwfne3y6oyikl4tm84bj9r50waxj37",
3532
"updated_at": "2015-05-01T12:08:10Z",
3633
"approval_status": "ACCEPTED",
3734
"deleted": false
@@ -42,7 +39,6 @@
4239
"timezone_switch_at": "2014-11-17T08:00:00Z",
4340
"id": "9ttgd",
4441
"created_at": "2015-06-24T18:51:20Z",
45-
"salt": "tj9hmt5xylm5zztrq05w7hwh4mkpkg5r",
4642
"updated_at": "2015-06-26T06:13:24Z",
4743
"approval_status": "ACCEPTED",
4844
"deleted": false
@@ -53,7 +49,6 @@
5349
"timezone_switch_at": "2013-05-22T07:00:00Z",
5450
"id": "47d0v",
5551
"created_at": "2015-05-28T05:42:03Z",
56-
"salt": "1ms1mq1nww7zl7169865gwqt89s9127m",
5752
"updated_at": "2015-05-28T05:42:03Z",
5853
"approval_status": "ACCEPTED",
5954
"deleted": false

tests/fixtures/line_items_all.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"ALL_ON_TWITTER"
1414
],
1515
"bid_amount_local_micro": 2000000,
16-
"automatically_select_bid": false,
1716
"advertiser_domain": null,
1817
"primary_web_event_tag": null,
1918
"pay_by": "ENGAGEMENT",
@@ -39,7 +38,6 @@
3938
"ALL_ON_TWITTER"
4039
],
4140
"bid_amount_local_micro": 2000000,
42-
"automatically_select_bid": false,
4341
"advertiser_domain": null,
4442
"primary_web_event_tag": null,
4543
"pay_by": "ENGAGEMENT",
@@ -65,7 +63,6 @@
6563
"TWITTER_SEARCH"
6664
],
6765
"bid_amount_local_micro": 100000,
68-
"automatically_select_bid": false,
6966
"advertiser_domain": null,
7067
"primary_web_event_tag": null,
7168
"pay_by": "ENGAGEMENT",
@@ -91,7 +88,6 @@
9188
"TWITTER_SEARCH"
9289
],
9390
"bid_amount_local_micro": 500000,
94-
"automatically_select_bid": false,
9591
"advertiser_domain": null,
9692
"primary_web_event_tag": null,
9793
"pay_by": "ENGAGEMENT",
@@ -117,7 +113,6 @@
117113
"TWITTER_TIMELINE"
118114
],
119115
"bid_amount_local_micro": 50000000,
120-
"automatically_select_bid": false,
121116
"advertiser_domain": null,
122117
"primary_web_event_tag": null,
123118
"pay_by": "ENGAGEMENT",
@@ -143,7 +138,6 @@
143138
"TWITTER_TIMELINE"
144139
],
145140
"bid_amount_local_micro": 50000000,
146-
"automatically_select_bid": false,
147141
"advertiser_domain": null,
148142
"primary_web_event_tag": null,
149143
"pay_by": "ENGAGEMENT",
@@ -169,7 +163,6 @@
169163
"TWITTER_SEARCH"
170164
],
171165
"bid_amount_local_micro": 50000000,
172-
"automatically_select_bid": false,
173166
"advertiser_domain": null,
174167
"primary_web_event_tag": null,
175168
"pay_by": "ENGAGEMENT",
@@ -195,7 +188,6 @@
195188
"TWITTER_TIMELINE"
196189
],
197190
"bid_amount_local_micro": 500000,
198-
"automatically_select_bid": false,
199191
"advertiser_domain": null,
200192
"primary_web_event_tag": null,
201193
"pay_by": "ENGAGEMENT",
@@ -221,7 +213,6 @@
221213
"TWITTER_SEARCH"
222214
],
223215
"bid_amount_local_micro": 50000000,
224-
"automatically_select_bid": false,
225216
"advertiser_domain": null,
226217
"primary_web_event_tag": null,
227218
"pay_by": "ENGAGEMENT",
@@ -247,7 +238,6 @@
247238
"TWITTER_TIMELINE"
248239
],
249240
"bid_amount_local_micro": 2009999,
250-
"automatically_select_bid": false,
251241
"advertiser_domain": null,
252242
"primary_web_event_tag": null,
253243
"pay_by": "ENGAGEMENT",

tests/fixtures/line_items_load.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"ALL_ON_TWITTER"
99
],
1010
"bid_amount_local_micro": 2000000,
11-
"automatically_select_bid": false,
1211
"advertiser_domain": null,
1312
"primary_web_event_tag": null,
1413
"pay_by": "ENGAGEMENT",

tests/test_audience_summary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from twitter_ads.account import Account
77
from twitter_ads.client import Client
8-
from twitter_ads.targeting import AudienceSummary
8+
from twitter_ads.targeting import AudienceEstimate
99
from twitter_ads import API_VERSION
1010

1111

@@ -17,8 +17,8 @@ def test_audience_summary():
1717
content_type='application/json')
1818

1919
responses.add(responses.POST,
20-
with_resource('/' + API_VERSION + '/accounts/2iqph/audience_summary'),
21-
body=with_fixture('audience_summary'),
20+
with_resource('/' + API_VERSION + '/accounts/2iqph/audience_estimate'),
21+
body=with_fixture('audience_estimate'),
2222
content_type='application/json')
2323

2424
client = Client(
@@ -51,7 +51,7 @@ def test_audience_summary():
5151
]
5252
}
5353

54-
audience_summary = AudienceSummary.load(
54+
audience_summary = AudienceEstimate.load(
5555
account=account,
5656
params=params
5757
)

twitter_ads/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (C) 2015 Twitter, Inc.
22

3-
VERSION = (9, 0, 1)
4-
API_VERSION = '9'
3+
4+
VERSION = (10, 0, 0)
5+
API_VERSION = '10'
56

67
from twitter_ads.utils import get_version
78

twitter_ads/account.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Card, VideoWebsiteCard, PromotedTweet)
1414
from twitter_ads.audience import CustomAudience
1515
from twitter_ads.campaign import (AppList, Campaign, FundingInstrument, LineItem,
16-
PromotableUser, ScheduledPromotedTweet)
16+
PromotableUser, TrackingTags, ScheduledPromotedTweet)
1717

1818

1919
class Account(Resource):
@@ -148,6 +148,12 @@ def scheduled_promoted_tweets(self, id=None, **kwargs):
148148
"""
149149
return self._load_resource(ScheduledPromotedTweet, id, **kwargs)
150150

151+
def tracking_tags(self, id=None, **kwargs):
152+
"""
153+
Returns a collection of Tracking Tags available to the current account.
154+
"""
155+
return self._load_resource(TrackingTags, id, **kwargs)
156+
151157
def video_website_cards(self, id=None, **kwargs):
152158
"""
153159
Returns a collection of video website cards available to the current account.
@@ -164,7 +170,6 @@ def cards(self, id=None, **kwargs):
164170
# account properties
165171
resource_property(Account, 'id', readonly=True)
166172
resource_property(Account, 'name', readonly=True)
167-
resource_property(Account, 'salt', readonly=True)
168173
resource_property(Account, 'timezone', readonly=True)
169174
resource_property(Account, 'approval_status', readonly=True)
170175
resource_property(Account, 'deleted', readonly=True, transform=TRANSFORM.BOOL)

twitter_ads/campaign.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ def tv_shows(klass, account, **kwargs):
141141
resource_property(TargetingCriteria, 'operator_type')
142142
resource_property(TargetingCriteria, 'targeting_type')
143143
resource_property(TargetingCriteria, 'targeting_value')
144-
resource_property(TargetingCriteria, 'custom_audience_expansion')
145144
# sdk-only
146145
resource_property(TargetingCriteria, 'to_delete', transform=TRANSFORM.BOOL)
147146

@@ -267,13 +266,6 @@ def targeting_criteria(self, id=None, **kwargs):
267266
return TargetingCriteria.load(self.account, id, **kwargs)
268267

269268
def save(self):
270-
# automatically_select_bid and bid_type are exclusive parameters
271-
if self.automatically_select_bid and self.bid_type:
272-
if self.bid_type == 'AUTO':
273-
self.bid_type = None
274-
self.automatically_select_bid = True
275-
else:
276-
self.automatically_select_bid = None
277269
super(LineItem, self).save()
278270

279271

@@ -289,7 +281,6 @@ def save(self):
289281
# writable
290282
resource_property(LineItem, 'advertiser_domain')
291283
resource_property(LineItem, 'advertiser_user_id')
292-
resource_property(LineItem, 'automatically_select_bid', transform=TRANSFORM.BOOL)
293284
resource_property(LineItem, 'bid_amount_local_micro')
294285
resource_property(LineItem, 'bid_strategy')
295286
resource_property(LineItem, 'campaign_id')
@@ -360,6 +351,26 @@ class ScheduledPromotedTweet(Resource, Persistence):
360351
resource_property(ScheduledPromotedTweet, 'scheduled_tweet_id')
361352

362353

354+
class TrackingTags(Resource, Persistence):
355+
356+
PROPERTIES = {}
357+
358+
RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/tracking_tags'
359+
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/tracking_tags/{id}'
360+
361+
362+
# tracking tags properties
363+
# read-only
364+
resource_property(TrackingTags, 'created_at', readonly=True, transform=TRANSFORM.TIME)
365+
resource_property(TrackingTags, 'id', readonly=True)
366+
resource_property(TrackingTags, 'deleted', readonly=True, transform=TRANSFORM.BOOL)
367+
resource_property(TrackingTags, 'updated_at', readonly=True, transform=TRANSFORM.TIME)
368+
# writable
369+
resource_property(TrackingTags, 'line_item_id')
370+
resource_property(TrackingTags, 'tracking_tag_type')
371+
resource_property(TrackingTags, 'tracking_tag_url')
372+
373+
363374
class Tweet(object):
364375

365376
TWEET_CREATE = '/' + API_VERSION + '/accounts/{account_id}/tweet'

twitter_ads/creative.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,8 @@ class ImageAppDownloadCard(Resource, Persistence):
209209
# writable
210210
resource_property(ImageAppDownloadCard, 'country_code')
211211
resource_property(ImageAppDownloadCard, 'app_cta')
212-
resource_property(ImageAppDownloadCard, 'iphone_app_id')
213-
resource_property(ImageAppDownloadCard, 'iphone_deep_link')
214-
resource_property(ImageAppDownloadCard, 'ipad_app_id')
215-
resource_property(ImageAppDownloadCard, 'ipad_deep_link')
212+
resource_property(ImageAppDownloadCard, 'ios_app_store_identifier')
213+
resource_property(ImageAppDownloadCard, 'ios_deep_link')
216214
resource_property(ImageAppDownloadCard, 'googleplay_app_id')
217215
resource_property(ImageAppDownloadCard, 'googleplay_deep_link')
218216
resource_property(ImageAppDownloadCard, 'name')
@@ -242,10 +240,8 @@ class VideoAppDownloadCard(Resource, Persistence):
242240
resource_property(VideoAppDownloadCard, 'country_code')
243241
resource_property(VideoAppDownloadCard, 'app_cta')
244242
resource_property(VideoAppDownloadCard, 'poster_media_key')
245-
resource_property(VideoAppDownloadCard, 'ipad_app_id')
246-
resource_property(VideoAppDownloadCard, 'ipad_deep_link')
247-
resource_property(VideoAppDownloadCard, 'iphone_app_id')
248-
resource_property(VideoAppDownloadCard, 'iphone_deep_link')
243+
resource_property(VideoAppDownloadCard, 'ios_app_store_identifier')
244+
resource_property(VideoAppDownloadCard, 'ios_deep_link')
249245
resource_property(VideoAppDownloadCard, 'googleplay_app_id')
250246
resource_property(VideoAppDownloadCard, 'googleplay_deep_link')
251247
resource_property(VideoAppDownloadCard, 'name')
@@ -530,10 +526,8 @@ def reload(self):
530526
resource_property(CardsFetch, 'image', readonly=True)
531527
resource_property(CardsFetch, 'image_display_height', readonly=True)
532528
resource_property(CardsFetch, 'image_display_width', readonly=True)
533-
resource_property(CardsFetch, 'ipad_app_id', readonly=True)
534-
resource_property(CardsFetch, 'ipad_deep_link', readonly=True)
535-
resource_property(CardsFetch, 'iphone_app_id', readonly=True)
536-
resource_property(CardsFetch, 'iphone_deep_link', readonly=True)
529+
resource_property(CardsFetch, 'ios_app_store_identifier', readonly=True)
530+
resource_property(CardsFetch, 'ios_deep_link', readonly=True)
537531
resource_property(CardsFetch, 'name', readonly=True)
538532
resource_property(CardsFetch, 'recipient_user_id', readonly=True)
539533
resource_property(CardsFetch, 'second_choice', readonly=True)
@@ -626,6 +620,7 @@ def reload(klass):
626620
# card properties
627621
# read-only
628622
resource_property(Card, 'card_uri', readonly=True)
623+
resource_property(Card, 'card_type', readonly=True)
629624
resource_property(Card, 'created_at', readonly=True, transform=TRANSFORM.TIME)
630625
resource_property(Card, 'deleted', readonly=True, transform=TRANSFORM.BOOL)
631626
resource_property(Card, 'updated_at', readonly=True, transform=TRANSFORM.TIME)

twitter_ads/targeting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import json
1010

1111

12-
class AudienceSummary(Resource, Persistence):
12+
class AudienceEstimate(Resource, Persistence):
1313
PROPERTIES = {}
1414

15-
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/audience_summary'
15+
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/audience_estimate'
1616

1717
@classmethod
1818
@FlattenParams
@@ -27,4 +27,4 @@ def load(klass, account, params):
2727
return klass(account).from_response(response.body['data'])
2828

2929

30-
resource_property(AudienceSummary, 'audience_size')
30+
resource_property(AudienceEstimate, 'audience_size')

0 commit comments

Comments
 (0)