Skip to content

Commit 3571144

Browse files
authored
Deprecation August, 2019 (#222)
* remvoe Audience Intelligence * remove old preview endpoints
1 parent 719fa5d commit 3571144

File tree

8 files changed

+0
-227
lines changed

8 files changed

+0
-227
lines changed

examples/audience_intelligence.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/draft_tweet.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@
4040
print(draft_tweet.id_str)
4141
print(draft_tweet.text)
4242

43-
# preview draft tweet of current instance (send notification)
44-
draft_tweet.preview()
45-
# or, specify any draft_tweet_id
46-
# draft_tweet.preview(draft_tweet_id='1142020720651673600')
47-
4843
# create a nullcasted tweet using draft tweet metadata
4944
tweet = Tweet.create(account, text=draft_tweet.text)
5045
print(tweet)

examples/scheduled_tweet.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
scheduled_tweet.scheduled_at = datetime.utcnow() + timedelta(days=2)
2323
scheduled_tweet.save()
2424

25-
# preview
26-
scheduled_tweet.preview()
27-
2825
# associate with a line item
2926
account.line_items().next().id
3027
scheduled_promoted_tweet = ScheduledPromotedTweet(account)

examples/tweet_preview.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

twitter_ads/audience.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from twitter_ads.error import BadRequest
99
from twitter_ads.cursor import Cursor
1010
from twitter_ads import API_VERSION
11-
from twitter_ads.utils import Deprecated
1211

1312
import json
1413

@@ -150,71 +149,3 @@ def delete(self):
150149
resource_property(TailoredAudiencePermission, 'tailored_audience_id')
151150
resource_property(TailoredAudiencePermission, 'granted_account_id')
152151
resource_property(TailoredAudiencePermission, 'permission_level')
153-
154-
155-
class AudienceIntelligence(Resource):
156-
157-
PROPERTIES = {}
158-
159-
RESOURCE_BASE = '/' + API_VERSION + '/accounts/{account_id}/audience_intelligence/'
160-
RESOURCE_CONVERSATIONS = RESOURCE_BASE + 'conversations'
161-
RESOURCE_DEMOGRAPHICS = RESOURCE_BASE + 'demographics'
162-
METHOD = 'post'
163-
HEADERS = {'Content-Type': 'application/json'}
164-
165-
@classmethod
166-
def __get(klass, account, client, params):
167-
"""
168-
Helper function to get the conversation data
169-
Returns a Cursor instance
170-
"""
171-
resource = klass.RESOURCE_CONVERSATIONS.format(account_id=account.id)
172-
173-
request = Request(
174-
account.client, klass.METHOD,
175-
resource, headers=klass.HEADERS, body=params)
176-
return Cursor(klass, request, init_with=[account])
177-
178-
@Deprecated('This endpoint has been deprecated and will no longer be available '
179-
'as of 2019-08-28')
180-
def conversations(self):
181-
"""
182-
Get the conversation topics for an input targeting criteria
183-
"""
184-
body = {
185-
"conversation_type": self.conversation_type,
186-
"audience_definition": self.audience_definition,
187-
"targeting_inputs": self.targeting_inputs
188-
}
189-
return self.__get(account=self.account, client=self.account.client, params=json.dumps(body))
190-
191-
@Deprecated('This endpoint has been deprecated and will no longer be available '
192-
'as of 2019-08-28')
193-
def demographics(self):
194-
"""
195-
Get the demographic breakdown for an input targeting criteria
196-
"""
197-
body = {
198-
"audience_definition": self.audience_definition,
199-
"targeting_inputs": self.targeting_inputs
200-
}
201-
resource = self.RESOURCE_DEMOGRAPHICS.format(account_id=self.account.id)
202-
response = Request(
203-
self.account.client, self.METHOD,
204-
resource, headers=self.HEADERS, body=json.dumps(body)).perform()
205-
return response.body['data']
206-
207-
208-
# tailored audience permission properties
209-
# read-only
210-
resource_property(AudienceIntelligence, 'operator_type', readonly=True)
211-
resource_property(AudienceIntelligence, 'targeting_type', readonly=True)
212-
resource_property(AudienceIntelligence, 'targeting_value', readonly=True)
213-
resource_property(AudienceIntelligence, 'localized', readonly=True)
214-
# writable
215-
resource_property(AudienceIntelligence, 'conversation_type')
216-
resource_property(AudienceIntelligence, 'targeting_inputs')
217-
resource_property(AudienceIntelligence, 'audience_definition')
218-
# demographics only
219-
resource_property(AudienceIntelligence, 'start_time', transform=TRANSFORM.TIME)
220-
resource_property(AudienceIntelligence, 'end_time', transform=TRANSFORM.TIME)

twitter_ads/campaign.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from twitter_ads.http import Request
88
from twitter_ads.cursor import Cursor
99
from twitter_ads import API_VERSION
10-
from twitter_ads.utils import Deprecated
1110

1211

1312
class TargetingCriteria(Resource, Persistence, Batch):
@@ -335,33 +334,12 @@ class ScheduledPromotedTweet(Resource, Persistence):
335334

336335
class Tweet(object):
337336

338-
TWEET_PREVIEW = '/' + API_VERSION + '/accounts/{account_id}/tweet/preview'
339-
TWEET_ID_PREVIEW = '/' + API_VERSION + '/accounts/{account_id}/tweet/preview/{id}'
340337
TWEET_CREATE = '/' + API_VERSION + '/accounts/{account_id}/tweet'
341338

342339
def __init__(self):
343340
raise NotImplementedError(
344341
'Error! {name} cannot be instantiated.'.format(name=self.__class__.__name__))
345342

346-
@classmethod
347-
@Deprecated('This endpoint has been deprecated and will no longer be available '
348-
'as of 2019-08-20')
349-
def preview(klass, account, **kwargs):
350-
"""
351-
Returns an HTML preview of a tweet, either new or existing.
352-
"""
353-
params = {}
354-
params.update(kwargs)
355-
356-
# handles array to string conversion for media IDs
357-
if 'media_ids' in params and isinstance(params['media_ids'], list):
358-
params['media_ids'] = ','.join(map(str, params['media_ids']))
359-
360-
resource = klass.TWEET_ID_PREVIEW if params.get('id') else klass.TWEET_PREVIEW
361-
resource = resource.format(account_id=account.id, id=params.get('id'))
362-
response = Request(account.client, 'get', resource, params=params).perform()
363-
return response.body['data']
364-
365343
@classmethod
366344
def create(klass, account, **kwargs):
367345
"""

twitter_ads/creative.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -337,19 +337,6 @@ class ScheduledTweet(Resource, Persistence):
337337

338338
RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/scheduled_tweets'
339339
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/scheduled_tweets/{id}'
340-
PREVIEW = '/' + API_VERSION + '/accounts/{account_id}/scheduled_tweets/preview/{id}'
341-
342-
@Deprecated('This endpoint has been deprecated and will no longer be available '
343-
'as of 2019-08-20')
344-
def preview(self):
345-
"""
346-
Returns an HTML preview for a Scheduled Tweet.
347-
"""
348-
if self.id:
349-
resource = self.PREVIEW
350-
resource = resource.format(account_id=self.account.id, id=self.id)
351-
response = Request(self.account.client, 'get', resource).perform()
352-
return response.body['data']
353340

354341

355342
# scheduled tweet properties
@@ -378,23 +365,6 @@ class DraftTweet(Resource, Persistence):
378365

379366
RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/draft_tweets'
380367
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/draft_tweets/{id}'
381-
PREVIEW = '/' + API_VERSION + '/accounts/{account_id}/draft_tweets/preview/{id}'
382-
383-
@Deprecated('This endpoint has been deprecated and will no longer be available '
384-
'as of 2019-08-20')
385-
def preview(self, draft_tweet_id=None):
386-
"""
387-
Preview a Draft Tweet on a mobile device.
388-
"""
389-
if not (draft_tweet_id is None):
390-
resource = self.PREVIEW.format(account_id=self.account.id, id=draft_tweet_id)
391-
elif self.id:
392-
resource = self.PREVIEW.format(account_id=self.account.id, id=self.id)
393-
else:
394-
raise AttributeError("object has no 'draft_tweet_id' to preview")
395-
396-
response = Request(self.account.client, 'post', resource).perform()
397-
return response.body
398368

399369

400370
# draft tweet properties

twitter_ads/enum.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,6 @@ def enum(**enums):
173173
REPLACE='REPLACE'
174174
)
175175

176-
AUDIENCE_DEFINITION = enum(
177-
KEYWORD_AUDIENCE='KEYWORD_AUDIENCE',
178-
TARGETING_CRITERIA='TARGETING_CRITERIA'
179-
)
180-
181176
CONVERSATION_TYPE = enum(
182177
HASHTAG='HASHTAG',
183178
HANDLE='TARGETING_CRITERIA',

0 commit comments

Comments
 (0)