Skip to content

Commit 7dcdf61

Browse files
committed
changes postretweet & destroyblock to use status_id and user_id, respectively
1 parent 2870359 commit 7dcdf61

2 files changed

Lines changed: 28 additions & 21 deletions

File tree

doc/migration_v30.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ Changes to Existing Methods
1414
* kwarg param has been changed to ``status_id`` from ``id`` to be consistent
1515
with other method calls and avoid shadowing builtin function ``id``.
1616

17+
:py:func:`twitter.api.Api.DestroyBlock`
18+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19+
* Kwarg ``id`` has been changed to ``user_id`` in order to avoid shadowing
20+
a builtin and be more descriptive.
21+
1722
:py:func:`twitter.api.Api.DestroyStatus`
1823
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19-
* Kwarg ``id`` has been changed to ``status_id`` in keeping with the rest of
24+
* kwarg ``id`` has been changed to ``status_id`` in keeping with the rest of
2025
the Api and to avoid shadowing a builtin.
2126

2227
:py:func:`twitter.api.Api.GetBlocks`
@@ -74,10 +79,8 @@ Changes to Existing Methods
7479
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7580
* Parameter 'stall_warning' is now 'stall_warnings' in line with GetStreamFilter and Twitter's naming convention. This should now actually return stall warnings, whereas it did not have any effect previously.
7681

77-
7882
:py:func:`twitter.api.Api.LookupFriendship`
7983
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
80-
8184
* Method will now accept a list for either ``user_id`` or ``screen_name``. The list can contain either ints, strings, or :py:mod:`twitter.user.User` objects for either ``user_id`` or ``screen_name``.
8285
* Return value is a list of :py:mod:`twitter.user.UserStatus` objects.
8386

@@ -87,6 +90,10 @@ Changes to Existing Methods
8790
* ``media_additional_owners`` should be a list of user ids representing Twitter users that should be able to use the uploaded media in their tweets. If you pass a list of media, then **additional owners will apply to each object.** If you need more granular control, please use the UploadMedia* methods.
8891
* ``media_category``: Only for use with the AdsAPI. See https://dev.twitter.com/ads/creative/promoted-video-overview if this applies to your application.
8992

93+
:py:func:`twitter.api.Api.PostRetweet`
94+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
95+
* Kwarg ``original_id`` has been changed to ``status_id`` in order to avoid shadowing
96+
a builtin and be more descriptive.
9097

9198
Deprecation
9299
===========

twitter/api.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ def GetStatusOembed(self,
785785
Specify tweet by the id or url parameter.
786786
787787
Args:
788-
id:
788+
status_id:
789789
The numeric ID of the status you are trying to embed.
790790
url:
791791
The url of the status you are trying to embed.
@@ -815,15 +815,15 @@ def GetStatusOembed(self,
815815

816816
parameters = {}
817817

818-
if id is not None:
818+
if status_id is not None:
819819
try:
820-
parameters['id'] = int(id)
820+
parameters['id'] = int(status_id)
821821
except ValueError:
822-
raise TwitterError({'message': "'id' must be an integer."})
822+
raise TwitterError({'message': "'status_id' must be an integer."})
823823
elif url is not None:
824824
parameters['url'] = url
825825
else:
826-
raise TwitterError({'message': "Must specify either 'id' or 'url'"})
826+
raise TwitterError({'message': "Must specify either 'status_id' or 'url'"})
827827

828828
if maxwidth is not None:
829829
parameters['maxwidth'] = maxwidth
@@ -858,7 +858,7 @@ def DestroyStatus(self, status_id, trim_user=False):
858858
status.
859859
860860
Args:
861-
id:
861+
status_id:
862862
The numerical ID of the status you're trying to destroy.
863863
864864
Returns:
@@ -867,7 +867,7 @@ def DestroyStatus(self, status_id, trim_user=False):
867867
try:
868868
post_data = {'id': int(status_id)}
869869
except ValueError:
870-
raise TwitterError({'message': "id must be an integer"})
870+
raise TwitterError({'message': "status_id must be an integer"})
871871
url = '%s/statuses/destroy/%s.json' % (self.base_url, status_id)
872872
if trim_user:
873873
post_data['trim_user'] = 1
@@ -1405,11 +1405,11 @@ def PostUpdates(self,
14051405

14061406
return results
14071407

1408-
def PostRetweet(self, original_id, trim_user=False):
1408+
def PostRetweet(self, status_id, trim_user=False):
14091409
"""Retweet a tweet with the Retweet API.
14101410
14111411
Args:
1412-
original_id:
1412+
status_id:
14131413
The numerical id of the tweet that will be retweeted
14141414
trim_user:
14151415
If True the returned payload will only contain the user IDs,
@@ -1420,13 +1420,13 @@ def PostRetweet(self, original_id, trim_user=False):
14201420
A twitter.Status instance representing the original tweet with retweet details embedded.
14211421
"""
14221422
try:
1423-
if int(original_id) <= 0:
1424-
raise TwitterError({'message': "'original_id' must be a positive number"})
1423+
if int(status_id) <= 0:
1424+
raise TwitterError({'message': "'status_id' must be a positive number"})
14251425
except ValueError:
1426-
raise TwitterError({'message': "'original_id' must be an integer"})
1426+
raise TwitterError({'message': "'status_id' must be an integer"})
14271427

1428-
url = '%s/statuses/retweet/%s.json' % (self.base_url, original_id)
1429-
data = {'id': original_id}
1428+
url = '%s/statuses/retweet/%s.json' % (self.base_url, status_id)
1429+
data = {'id': status_id}
14301430
if trim_user:
14311431
data['trim_user'] = 'true'
14321432
resp = self._RequestUrl(url, 'POST', data=data)
@@ -1770,24 +1770,24 @@ def GetBlocksIDs(self,
17701770

17711771
return result
17721772

1773-
def DestroyBlock(self, id, trim_user=False):
1773+
def DestroyBlock(self, user_id, trim_user=False):
17741774
"""Destroys the block for the user specified by the required ID
17751775
parameter.
17761776
17771777
The authenticating user must have blocked the user specified by the
17781778
required ID parameter.
17791779
17801780
Args:
1781-
id:
1781+
user_id:
17821782
The numerical ID of the user to be un-blocked.
17831783
17841784
Returns:
17851785
A twitter.User instance representing the un-blocked user.
17861786
"""
17871787
try:
1788-
post_data = {'user_id': int(id)}
1788+
post_data = {'user_id': int(user_id)}
17891789
except ValueError:
1790-
raise TwitterError({'message': "id must be an integer"})
1790+
raise TwitterError({'message': "user_id must be an integer"})
17911791
url = '%s/blocks/destroy.json' % (self.base_url)
17921792
if trim_user:
17931793
post_data['trim_user'] = 1

0 commit comments

Comments
 (0)