Skip to content
Browse files

changes postretweet & destroyblock to use status_id and user_id, resp…

…ectively
  • Loading branch information...
1 parent 2870359 commit 7dcdf61fe93fa2a65cd1555e7650021fc6f7081e @jeremylow jeremylow committed Mar 27, 2016
Showing with 28 additions and 21 deletions.
  1. +10 −3 doc/migration_v30.rst
  2. +18 −18 twitter/api.py
View
13 doc/migration_v30.rst
@@ -14,9 +14,14 @@ Changes to Existing Methods
* kwarg param has been changed to ``status_id`` from ``id`` to be consistent
with other method calls and avoid shadowing builtin function ``id``.
+:py:func:`twitter.api.Api.DestroyBlock`
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+* Kwarg ``id`` has been changed to ``user_id`` in order to avoid shadowing
+ a builtin and be more descriptive.
+
:py:func:`twitter.api.Api.DestroyStatus`
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-* Kwarg ``id`` has been changed to ``status_id`` in keeping with the rest of
+* kwarg ``id`` has been changed to ``status_id`` in keeping with the rest of
the Api and to avoid shadowing a builtin.
:py:func:`twitter.api.Api.GetBlocks`
@@ -74,10 +79,8 @@ Changes to Existing Methods
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* 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.
-
:py:func:`twitter.api.Api.LookupFriendship`
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
* 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``.
* Return value is a list of :py:mod:`twitter.user.UserStatus` objects.
@@ -87,6 +90,10 @@ Changes to Existing Methods
* ``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.
* ``media_category``: Only for use with the AdsAPI. See https://dev.twitter.com/ads/creative/promoted-video-overview if this applies to your application.
+:py:func:`twitter.api.Api.PostRetweet`
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+* Kwarg ``original_id`` has been changed to ``status_id`` in order to avoid shadowing
+ a builtin and be more descriptive.
Deprecation
===========
View
36 twitter/api.py
@@ -785,7 +785,7 @@ def GetStatusOembed(self,
Specify tweet by the id or url parameter.
Args:
- id:
+ status_id:
The numeric ID of the status you are trying to embed.
url:
The url of the status you are trying to embed.
@@ -815,15 +815,15 @@ def GetStatusOembed(self,
parameters = {}
- if id is not None:
+ if status_id is not None:
try:
- parameters['id'] = int(id)
+ parameters['id'] = int(status_id)
except ValueError:
- raise TwitterError({'message': "'id' must be an integer."})
+ raise TwitterError({'message': "'status_id' must be an integer."})
elif url is not None:
parameters['url'] = url
else:
- raise TwitterError({'message': "Must specify either 'id' or 'url'"})
+ raise TwitterError({'message': "Must specify either 'status_id' or 'url'"})
if maxwidth is not None:
parameters['maxwidth'] = maxwidth
@@ -858,7 +858,7 @@ def DestroyStatus(self, status_id, trim_user=False):
status.
Args:
- id:
+ status_id:
The numerical ID of the status you're trying to destroy.
Returns:
@@ -867,7 +867,7 @@ def DestroyStatus(self, status_id, trim_user=False):
try:
post_data = {'id': int(status_id)}
except ValueError:
- raise TwitterError({'message': "id must be an integer"})
+ raise TwitterError({'message': "status_id must be an integer"})
url = '%s/statuses/destroy/%s.json' % (self.base_url, status_id)
if trim_user:
post_data['trim_user'] = 1
@@ -1405,11 +1405,11 @@ def PostUpdates(self,
return results
- def PostRetweet(self, original_id, trim_user=False):
+ def PostRetweet(self, status_id, trim_user=False):
"""Retweet a tweet with the Retweet API.
Args:
- original_id:
+ status_id:
The numerical id of the tweet that will be retweeted
trim_user:
If True the returned payload will only contain the user IDs,
@@ -1420,13 +1420,13 @@ def PostRetweet(self, original_id, trim_user=False):
A twitter.Status instance representing the original tweet with retweet details embedded.
"""
try:
- if int(original_id) <= 0:
- raise TwitterError({'message': "'original_id' must be a positive number"})
+ if int(status_id) <= 0:
+ raise TwitterError({'message': "'status_id' must be a positive number"})
except ValueError:
- raise TwitterError({'message': "'original_id' must be an integer"})
+ raise TwitterError({'message': "'status_id' must be an integer"})
- url = '%s/statuses/retweet/%s.json' % (self.base_url, original_id)
- data = {'id': original_id}
+ url = '%s/statuses/retweet/%s.json' % (self.base_url, status_id)
+ data = {'id': status_id}
if trim_user:
data['trim_user'] = 'true'
resp = self._RequestUrl(url, 'POST', data=data)
@@ -1770,24 +1770,24 @@ def GetBlocksIDs(self,
return result
- def DestroyBlock(self, id, trim_user=False):
+ def DestroyBlock(self, user_id, trim_user=False):
"""Destroys the block for the user specified by the required ID
parameter.
The authenticating user must have blocked the user specified by the
required ID parameter.
Args:
- id:
+ user_id:
The numerical ID of the user to be un-blocked.
Returns:
A twitter.User instance representing the un-blocked user.
"""
try:
- post_data = {'user_id': int(id)}
+ post_data = {'user_id': int(user_id)}
except ValueError:
- raise TwitterError({'message': "id must be an integer"})
+ raise TwitterError({'message': "user_id must be an integer"})
url = '%s/blocks/destroy.json' % (self.base_url)
if trim_user:
post_data['trim_user'] = 1

0 comments on commit 7dcdf61

Please sign in to comment.
Something went wrong with that request. Please try again.