Skip to content

Commit 60cea44

Browse files
author
Tom Osowski
authored
Revert "Remove deprecated cards endpoints (#276)" (#281)
This reverts commit 462d3ca.
1 parent 17ffd57 commit 60cea44

File tree

4 files changed

+138
-6
lines changed

4 files changed

+138
-6
lines changed

examples/promoted_tweet.py

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

33
from twitter_ads.client import Client
44
from twitter_ads.campaign import Tweet
5-
from twitter_ads.creative import Card, PromotedTweet
5+
from twitter_ads.creative import PromotedTweet, WebsiteCard
66
from twitter_ads.restapi import UserIdLookup
77

88
CONSUMER_KEY = 'your consumer key'
@@ -26,13 +26,13 @@
2626
# create request for a simple nullcasted tweet
2727
tweet1 = Tweet.create(account, text='There can be only one...', as_user_id=user_id)
2828

29-
# create request for a nullcasted tweet with a card
30-
card = Card.all(account).next()
29+
# create request for a nullcasted tweet with a website card
30+
website_card = WebsiteCard.all(account).next()
3131
tweet2 = Tweet.create(
3232
account,
3333
text='Fine. There can be two.',
3434
as_user_id=user_id,
35-
card_uri=card.card_uri)
35+
card_uri=website_card.card_uri)
3636

3737
# promote the tweet using our line item
3838
tweet_ids = [tweet1['id'], tweet2['id']]

twitter_ads/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (C) 2015 Twitter, Inc.
22

3-
VERSION = (9, 0, 0)
3+
VERSION = (9, 0, 1)
44
API_VERSION = '9'
55

66
from twitter_ads.utils import get_version

twitter_ads/account.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from twitter_ads.resource import resource_property, Resource
1212
from twitter_ads.creative import (AccountMedia, MediaCreative, ScheduledTweet,
13-
Card, PromotedTweet)
13+
Card, VideoWebsiteCard, PromotedTweet)
1414
from twitter_ads.audience import CustomAudience
1515
from twitter_ads.campaign import (AppList, Campaign, FundingInstrument, LineItem,
1616
PromotableUser, ScheduledPromotedTweet)
@@ -148,6 +148,12 @@ def scheduled_promoted_tweets(self, id=None, **kwargs):
148148
"""
149149
return self._load_resource(ScheduledPromotedTweet, id, **kwargs)
150150

151+
def video_website_cards(self, id=None, **kwargs):
152+
"""
153+
Returns a collection of video website cards available to the current account.
154+
"""
155+
return self._load_resource(VideoWebsiteCard, id, **kwargs)
156+
151157
def cards(self, id=None, **kwargs):
152158
"""
153159
Returns a collection of Cards available to the current account.

twitter_ads/creative.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,132 @@ class MediaCreative(Analytics, Resource, Persistence):
126126
resource_property(MediaCreative, 'line_item_id')
127127

128128

129+
class WebsiteCard(Resource, Persistence):
130+
131+
PROPERTIES = {}
132+
133+
RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/cards/website'
134+
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/cards/website/{id}'
135+
136+
137+
# website card properties
138+
# read-only
139+
resource_property(WebsiteCard, 'card_type', readonly=True)
140+
resource_property(WebsiteCard, 'card_uri', readonly=True)
141+
resource_property(WebsiteCard, 'created_at', readonly=True, transform=TRANSFORM.TIME)
142+
resource_property(WebsiteCard, 'id', readonly=True)
143+
resource_property(WebsiteCard, 'media_url', readonly=True)
144+
resource_property(WebsiteCard, 'image_display_height', readonly=True)
145+
resource_property(WebsiteCard, 'image_display_width', readonly=True)
146+
resource_property(WebsiteCard, 'deleted', readonly=True, transform=TRANSFORM.BOOL)
147+
resource_property(WebsiteCard, 'website_dest_url', readonly=True)
148+
resource_property(WebsiteCard, 'website_display_url', readonly=True)
149+
resource_property(WebsiteCard, 'updated_at', readonly=True, transform=TRANSFORM.TIME)
150+
# writable
151+
resource_property(WebsiteCard, 'media_key')
152+
resource_property(WebsiteCard, 'name')
153+
resource_property(WebsiteCard, 'website_title')
154+
resource_property(WebsiteCard, 'website_url')
155+
156+
157+
class VideoWebsiteCard(Resource, Persistence):
158+
159+
PROPERTIES = {}
160+
161+
RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/cards/video_website'
162+
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/cards/video_website/{id}'
163+
164+
165+
# video website card properties
166+
# read-only
167+
resource_property(VideoWebsiteCard, 'account_id', readonly=True)
168+
resource_property(VideoWebsiteCard, 'card_type', readonly=True)
169+
resource_property(VideoWebsiteCard, 'card_uri', readonly=True)
170+
resource_property(VideoWebsiteCard, 'created_at', readonly=True, transform=TRANSFORM.TIME)
171+
resource_property(VideoWebsiteCard, 'deleted', readonly=True, transform=TRANSFORM.BOOL)
172+
resource_property(VideoWebsiteCard, 'id', readonly=True)
173+
resource_property(VideoWebsiteCard, 'updated_at', readonly=True, transform=TRANSFORM.TIME)
174+
resource_property(VideoWebsiteCard, 'video_height', readonly=True)
175+
resource_property(VideoWebsiteCard, 'video_owner_id', readonly=True)
176+
resource_property(VideoWebsiteCard, 'video_poster_height', readonly=True)
177+
resource_property(VideoWebsiteCard, 'poster_media_url', readonly=True)
178+
resource_property(VideoWebsiteCard, 'video_poster_width', readonly=True)
179+
resource_property(VideoWebsiteCard, 'media_url', readonly=True)
180+
resource_property(VideoWebsiteCard, 'video_width', readonly=True)
181+
resource_property(VideoWebsiteCard, 'website_dest_url', readonly=True)
182+
resource_property(VideoWebsiteCard, 'website_display_url', readonly=True)
183+
# writable
184+
resource_property(VideoWebsiteCard, 'name')
185+
resource_property(VideoWebsiteCard, 'title')
186+
resource_property(VideoWebsiteCard, 'media_key')
187+
resource_property(VideoWebsiteCard, 'website_url')
188+
189+
190+
class ImageAppDownloadCard(Resource, Persistence):
191+
192+
PROPERTIES = {}
193+
194+
RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/cards/image_app_download'
195+
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/cards/image_app_download/{id}'
196+
197+
198+
# image app download card properties
199+
# read-only
200+
resource_property(ImageAppDownloadCard, 'id', readonly=True)
201+
resource_property(ImageAppDownloadCard, 'image_display_height', readonly=True)
202+
resource_property(ImageAppDownloadCard, 'image_display_width', readonly=True)
203+
resource_property(ImageAppDownloadCard, 'media_url', readonly=True)
204+
resource_property(ImageAppDownloadCard, 'card_uri', readonly=True)
205+
resource_property(ImageAppDownloadCard, 'card_type', readonly=True)
206+
resource_property(ImageAppDownloadCard, 'created_at', readonly=True, transform=TRANSFORM.TIME)
207+
resource_property(ImageAppDownloadCard, 'updated_at', readonly=True, transform=TRANSFORM.TIME)
208+
resource_property(ImageAppDownloadCard, 'deleted', readonly=True, transform=TRANSFORM.BOOL)
209+
# writable
210+
resource_property(ImageAppDownloadCard, 'country_code')
211+
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')
216+
resource_property(ImageAppDownloadCard, 'googleplay_app_id')
217+
resource_property(ImageAppDownloadCard, 'googleplay_deep_link')
218+
resource_property(ImageAppDownloadCard, 'name')
219+
resource_property(ImageAppDownloadCard, 'media_key')
220+
221+
222+
class VideoAppDownloadCard(Resource, Persistence):
223+
224+
PROPERTIES = {}
225+
226+
RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/cards/video_app_download'
227+
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/cards/video_app_download/{id}'
228+
229+
230+
# video app download card properties
231+
# read-only
232+
resource_property(VideoAppDownloadCard, 'card_uri', readonly=True)
233+
resource_property(VideoAppDownloadCard, 'card_type', readonly=True)
234+
resource_property(VideoAppDownloadCard, 'created_at', readonly=True, transform=TRANSFORM.TIME)
235+
resource_property(VideoAppDownloadCard, 'deleted', readonly=True, transform=TRANSFORM.BOOL)
236+
resource_property(VideoAppDownloadCard, 'id', readonly=True)
237+
resource_property(VideoAppDownloadCard, 'updated_at', readonly=True, transform=TRANSFORM.TIME)
238+
resource_property(VideoAppDownloadCard, 'video_owner_id', readonly=True)
239+
resource_property(VideoAppDownloadCard, 'poster_media_url', readonly=True)
240+
resource_property(VideoAppDownloadCard, 'media_url', readonly=True)
241+
# writable
242+
resource_property(VideoAppDownloadCard, 'country_code')
243+
resource_property(VideoAppDownloadCard, 'app_cta')
244+
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')
249+
resource_property(VideoAppDownloadCard, 'googleplay_app_id')
250+
resource_property(VideoAppDownloadCard, 'googleplay_deep_link')
251+
resource_property(VideoAppDownloadCard, 'name')
252+
resource_property(VideoAppDownloadCard, 'media_key')
253+
254+
129255
class ImageConversationCard(Resource, Persistence):
130256

131257
PROPERTIES = {}

0 commit comments

Comments
 (0)