Skip to content

Commit

Permalink
Add promoted tweets to accounts and targeting options to targeting cr…
Browse files Browse the repository at this point in the history
…iteria (xdevplatform#161)
  • Loading branch information
mchristopher authored and juanshishido committed Mar 23, 2018
1 parent 22cb40a commit 322fc8b
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
8 changes: 7 additions & 1 deletion twitter_ads/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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

def promoted_tweets(self, id=None, **kwargs):
"""
Returns a collection of promoted tweets available to the current account.
"""
return self._load_resource(PromotedTweet, id, **kwargs)

def scheduled_promoted_tweets(self, id=None, **kwargs):
"""
Returns a collection of Scheduled Promoted Tweets available to the current account.
Expand Down
92 changes: 92 additions & 0 deletions twitter_ads/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TargetingCriteria(Resource, Persistence, Batch):
targeting_criteria'
RESOURCE_COLLECTION = '/' + API_VERSION + '/accounts/{account_id}/targeting_criteria'
RESOURCE = '/' + API_VERSION + '/accounts/{account_id}/targeting_criteria/{id}'
RESOURCE_OPTIONS = '/' + API_VERSION + '/targeting_criteria/'

@classmethod
def all(klass, account, line_item_id, **kwargs):
Expand All @@ -29,6 +30,97 @@ def all(klass, account, line_item_id, **kwargs):

return Cursor(klass, request, init_with=[account])

@classmethod
def app_store_categories(klass, account, **kwargs):
"""Returns a list of supported app store categories"""
resource = klass.RESOURCE_OPTIONS + 'app_store_categories'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def behavior_taxonomies(klass, account, **kwargs):
"""Returns a list of supported behavior taxonomies"""
resource = klass.RESOURCE_OPTIONS + 'behavior_taxonomies'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def behaviors(klass, account, **kwargs):
"""Returns a list of supported behaviors"""
resource = klass.RESOURCE_OPTIONS + 'behaviors'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def devices(klass, account, **kwargs):
"""Returns a list of supported devices"""
resource = klass.RESOURCE_OPTIONS + 'devices'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def events(klass, account, **kwargs):
"""Returns a list of supported events"""
resource = klass.RESOURCE_OPTIONS + 'events'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def interests(klass, account, **kwargs):
"""Returns a list of supported interests"""
resource = klass.RESOURCE_OPTIONS + 'interests'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def languages(klass, account, **kwargs):
"""Returns a list of supported languages"""
resource = klass.RESOURCE_OPTIONS + 'languages'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def locations(klass, account, **kwargs):
"""Returns a list of supported locations"""
resource = klass.RESOURCE_OPTIONS + 'locations'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def network_operators(klass, account, **kwargs):
"""Returns a list of supported network operators"""
resource = klass.RESOURCE_OPTIONS + 'network_operators'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def platforms(klass, account, **kwargs):
"""Returns a list of supported platforms"""
resource = klass.RESOURCE_OPTIONS + 'platforms'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def platform_versions(klass, account, **kwargs):
"""Returns a list of supported platform versions"""
resource = klass.RESOURCE_OPTIONS + 'platform_versions'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def tv_markets(klass, account, **kwargs):
"""Returns a list of supported TV markets"""
resource = klass.RESOURCE_OPTIONS + 'tv_markets'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)

@classmethod
def tv_shows(klass, account, **kwargs):
"""Returns a list of supported TV shows"""
resource = klass.RESOURCE_OPTIONS + 'tv_shows'
request = Request(account.client, 'get', resource, params=kwargs)
return Cursor(None, request)


# targeting criteria properties
# read-only
Expand Down

0 comments on commit 322fc8b

Please sign in to comment.