Skip to content

Commit 2870359

Browse files
committed
fix up a few more "id" params & add documentation for same.
1 parent 4428fb0 commit 2870359

2 files changed

Lines changed: 31 additions & 22 deletions

File tree

doc/migration_v30.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ 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.DestroyStatus`
18+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19+
* Kwarg ``id`` has been changed to ``status_id`` in keeping with the rest of
20+
the Api and to avoid shadowing a builtin.
21+
1722
:py:func:`twitter.api.Api.GetBlocks`
1823
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1924
* Method no longer accepts parameters ``user_id`` or ``screen_name`` as these are not honored by Twitter. The data returned will be for the authenticated user only.
@@ -45,6 +50,10 @@ Changes to Existing Methods
4550
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4651
* No longer accepts ``cursor`` parameter. If you require granular control over the paging of the twitter.list.List members, please user twitter.api.Api.GetListMembersPaged instead.
4752

53+
:py:func:`twitter.api.Api.GetStatus`
54+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55+
* Kwarg ``id`` has been changed to ``status_id`` in keeping with the rest of
56+
the Api and to avoid shadowing a builtin.
4857

4958
:py:func:`twitter.api.Api.GetStatusOembed`
5059
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

twitter/api.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ class Api(object):
106106
>>> api.GetReplies()
107107
>>> api.GetUserTimeline(user)
108108
>>> api.GetHomeTimeline()
109-
>>> api.GetStatus(id)
110-
>>> api.DestroyStatus(id)
109+
>>> api.GetStatus(status_id)
110+
>>> api.DestroyStatus(status_id)
111111
>>> api.GetFriends(user)
112112
>>> api.GetFollowers()
113113
>>> api.GetFeatured()
114114
>>> api.GetDirectMessages()
115115
>>> api.GetSentDirectMessages()
116116
>>> api.PostDirectMessage(user, text)
117-
>>> api.DestroyDirectMessage(id)
117+
>>> api.DestroyDirectMessage(message_id)
118118
>>> api.DestroyFriendship(user)
119119
>>> api.CreateFriendship(user)
120120
>>> api.LookupFriendship(user)
@@ -722,14 +722,14 @@ def GetUserTimeline(self,
722722
return [Status.NewFromJsonDict(x) for x in data]
723723

724724
def GetStatus(self,
725-
id,
725+
status_id,
726726
trim_user=False,
727727
include_my_retweet=True,
728728
include_entities=True):
729-
"""Returns a single status message, specified by the id parameter.
729+
"""Returns a single status message, specified by the status_id parameter.
730730
731731
Args:
732-
id:
732+
status_id:
733733
The numeric ID of the status you are trying to retrieve.
734734
trim_user:
735735
When set to True, each tweet returned in a timeline will include
@@ -753,9 +753,9 @@ def GetStatus(self,
753753
parameters = {}
754754

755755
try:
756-
parameters['id'] = int(id)
756+
parameters['id'] = int(status_id)
757757
except ValueError:
758-
raise TwitterError({'message': "'id' must be an integer."})
758+
raise TwitterError({'message': "'status_id' must be an integer."})
759759

760760
if trim_user:
761761
parameters['trim_user'] = 1
@@ -851,7 +851,7 @@ def GetStatusOembed(self,
851851

852852
return data
853853

854-
def DestroyStatus(self, id, trim_user=False):
854+
def DestroyStatus(self, status_id, trim_user=False):
855855
"""Destroys the status specified by the required ID parameter.
856856
857857
The authenticating user must be the author of the specified
@@ -865,10 +865,10 @@ def DestroyStatus(self, id, trim_user=False):
865865
A twitter.Status instance representing the destroyed status message
866866
"""
867867
try:
868-
post_data = {'id': int(id)}
868+
post_data = {'id': int(status_id)}
869869
except ValueError:
870870
raise TwitterError({'message': "id must be an integer"})
871-
url = '%s/statuses/destroy/%s.json' % (self.base_url, id)
871+
url = '%s/statuses/destroy/%s.json' % (self.base_url, status_id)
872872
if trim_user:
873873
post_data['trim_user'] = 1
874874

@@ -2639,21 +2639,21 @@ def PostDirectMessage(self,
26392639

26402640
return DirectMessage.NewFromJsonDict(data)
26412641

2642-
def DestroyDirectMessage(self, id, include_entities=True):
2642+
def DestroyDirectMessage(self, message_id, include_entities=True):
26432643
"""Destroys the direct message specified in the required ID parameter.
26442644
26452645
The twitter.Api instance must be authenticated, and the
26462646
authenticating user must be the recipient of the specified direct
26472647
message.
26482648
26492649
Args:
2650-
id: The id of the direct message to be destroyed
2650+
message_id: The id of the direct message to be destroyed
26512651
26522652
Returns:
26532653
A twitter.DirectMessage instance representing the message destroyed
26542654
"""
26552655
url = '%s/direct_messages/destroy.json' % self.base_url
2656-
data = {'id': id}
2656+
data = {'id': message_id}
26572657
if not include_entities:
26582658
data['include_entities'] = 'false'
26592659

@@ -2816,7 +2816,7 @@ def CreateFavorite(self,
28162816
Returns the favorite status when successful.
28172817
28182818
Args:
2819-
id:
2819+
status_id:
28202820
The id of the twitter status to mark as a favorite. [Optional]
28212821
status:
28222822
The twitter.Status object to mark as a favorite. [Optional]
@@ -2828,12 +2828,12 @@ def CreateFavorite(self,
28282828
"""
28292829
url = '%s/favorites/create.json' % self.base_url
28302830
data = {}
2831-
if id:
2832-
data['id'] = id
2831+
if status_id:
2832+
data['id'] = status_id
28332833
elif status:
28342834
data['id'] = status.id
28352835
else:
2836-
raise TwitterError({'message': "Specify id or status"})
2836+
raise TwitterError({'message': "Specify status_id or status"})
28372837
if not include_entities:
28382838
data['include_entities'] = 'false'
28392839

@@ -2851,7 +2851,7 @@ def DestroyFavorite(self,
28512851
Returns the un-favorited status when successful.
28522852
28532853
Args:
2854-
id:
2854+
status_id:
28552855
The id of the twitter status to unmark as a favorite. [Optional]
28562856
status:
28572857
The twitter.Status object to unmark as a favorite. [Optional]
@@ -2863,12 +2863,12 @@ def DestroyFavorite(self,
28632863
"""
28642864
url = '%s/favorites/destroy.json' % self.base_url
28652865
data = {}
2866-
if id:
2867-
data['id'] = id
2866+
if status_id:
2867+
data['id'] = status_id
28682868
elif status:
28692869
data['id'] = status.id
28702870
else:
2871-
raise TwitterError({'message': "Specify id or status"})
2871+
raise TwitterError({'message': "Specify status_id or status"})
28722872
if not include_entities:
28732873
data['include_entities'] = 'false'
28742874

0 commit comments

Comments
 (0)