Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion twitter_ads/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2015 Twitter, Inc.

VERSION = (1, 2, 3)
API_VERSION = '1'
API_VERSION = '2'

from twitter_ads.utils import get_version

Expand Down
8 changes: 7 additions & 1 deletion twitter_ads/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from twitter_ads import API_VERSION

from twitter_ads.resource import resource_property, Resource
from twitter_ads.creative import AccountMedia, MediaCreative, Video
from twitter_ads.creative import AccountMedia, MediaCreative, Video, VideoWebsiteCard
from twitter_ads.audience import TailoredAudience
from twitter_ads.campaign import (FundingInstrument, Campaign, LineItem,
AppList, PromotableUser)
Expand Down Expand Up @@ -136,6 +136,12 @@ def media_creatives(self, id=None, **kwargs):
"""
return self._load_resource(MediaCreative, id, **kwargs)

def video_website_cards(self, id=None, **kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is needed because the other card formats also use just the RESOURCE_COLLECTION?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that including this under the Account class let's us retrieve the video website cards that belong to the particular account.

For example:

In [3]: client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
   ...: account = client.accounts(ACCOUNT_ID)
   ...: 

In [4]: vwcs = account.video_website_cards()

In [5]: type(vwcs)
Out[5]: twitter_ads.cursor.Cursor

In [6]: vwcs.first.id
Out[6]: u'455hx'

In [7]: vwcs.first.card_uri
Out[7]: u'card://860983079292198912'

In [8]: vwcs.first.card_type
Out[8]: u'VIDEO_WEBSITE'

You can do this type of thing for any method (entity) defined under the Account class.

"""
Returns a collection of video website cards available to the current account.
"""
return self._load_resource(VideoWebsiteCard, id, **kwargs)

def scoped_timeline(self, *id, **kwargs):
"""
Returns the most recent promotable Tweets created by the specified Twitter user.
Expand Down
35 changes: 35 additions & 0 deletions twitter_ads/creative.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,41 @@ class WebsiteCard(Resource, Persistence):
resource_property(WebsiteCard, 'image_media_id')


class VideoWebsiteCard(Resource, Persistence):

PROPERTIES = {}

RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/cards/video_website'
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/cards/video_website/{id}'

# video website card properties
# read-only
resource_property(VideoWebsiteCard, 'account_id', readonly=True)
resource_property(VideoWebsiteCard, 'card_type', readonly=True)
resource_property(VideoWebsiteCard, 'card_uri', readonly=True)
resource_property(VideoWebsiteCard, 'created_at', readonly=True, transform=TRANSFORM.TIME)
resource_property(VideoWebsiteCard, 'deleted', readonly=True, transform=TRANSFORM.BOOL)
resource_property(VideoWebsiteCard, 'id', readonly=True)
resource_property(VideoWebsiteCard, 'preview_url', readonly=True)
resource_property(VideoWebsiteCard, 'updated_at', readonly=True, transform=TRANSFORM.TIME)
resource_property(VideoWebsiteCard, 'video_content_id', readonly=True)
resource_property(VideoWebsiteCard, 'video_height', readonly=True)
resource_property(VideoWebsiteCard, 'video_hls_url', readonly=True)
resource_property(VideoWebsiteCard, 'video_owner_id', readonly=True)
resource_property(VideoWebsiteCard, 'video_poster_height', readonly=True)
resource_property(VideoWebsiteCard, 'video_poster_url', readonly=True)
resource_property(VideoWebsiteCard, 'video_poster_width', readonly=True)
resource_property(VideoWebsiteCard, 'video_url', readonly=True)
resource_property(VideoWebsiteCard, 'video_width', readonly=True)
resource_property(VideoWebsiteCard, 'website_dest_url', readonly=True)
resource_property(VideoWebsiteCard, 'website_display_url', readonly=True)
# writable
resource_property(VideoWebsiteCard, 'name')
resource_property(VideoWebsiteCard, 'title')
resource_property(VideoWebsiteCard, 'video_id')
resource_property(VideoWebsiteCard, 'website_url')


class LeadGenCard(Resource, Persistence):

PROPERTIES = {}
Expand Down