Skip to content

Commit a590dcf

Browse files
committed
Merge pull request #39 from jackMort/master
[bug] fixing promoted tweet create/update
2 parents 298d1f6 + 3aef7c5 commit a590dcf

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

twitter_ads/creative.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,19 @@ def save(self):
4141
Saves or updates the current object instance depending on the
4242
presence of `object.id`.
4343
"""
44-
if self.id:
45-
method = 'put'
46-
resource = self.RESOURCE.format(account_id=self.account.id, id=self.id)
47-
else:
48-
method = 'post'
49-
resource = self.RESOURCE_COLLECTION.format(account_id=self.account.id)
50-
5144
params = self.to_params()
5245
if 'tweet_id' in params:
5346
params['tweet_ids'] = [params['tweet_id']]
5447
del params['tweet_id']
5548

56-
response = Request(
57-
self.account.client, method,
58-
resource, params=params).perform()
49+
if self.id:
50+
resource = self.RESOURCE.format(account_id=self.account.id, id=self.id)
51+
response = Request(self.account.client, 'put', resource, params=params).perform()
52+
return self.from_response(response.body['data'])
5953

60-
self.from_response(response.body['data'])
54+
resource = self.RESOURCE_COLLECTION.format(account_id=self.account.id)
55+
response = Request(self.account.client, 'post', resource, params=params).perform()
56+
return self.from_response(response.body['data'][0])
6157

6258
# promoted tweet properties
6359
# read-only

0 commit comments

Comments
 (0)