From: Harmon Date: Wed, 7 Apr 2021 13:36:16 +0000 (-0500) Subject: Update and improve documentation for API.retweet X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e66f732f085fd53a69eec23942dac10702d14f12;p=tweepy.git Update and improve documentation for API.retweet Automatically use docstring for documentation Improve method and documentation order Add documentation for trim_user parameter Improve capitalization --- diff --git a/docs/api.rst b/docs/api.rst index dcd9368..f851b6a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -51,6 +51,8 @@ Post, retrieve, and engage with Tweets .. automethod:: API.destroy_status +.. automethod:: API.retweet + Status methods -------------- @@ -153,14 +155,6 @@ Status methods :rtype: :class:`Status` object -.. method:: API.retweet(id) - - Retweets a tweet. Requires the id of the tweet you are retweeting. - - :param id: |sid| - :rtype: :class:`Status` object - - .. method:: API.unretweet(id) Untweets a retweeted status. Requires the id of the retweet to unretweet. diff --git a/tweepy/api.py b/tweepy/api.py index 9ca0a12..ef8e5a6 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -626,6 +626,25 @@ class API: ), **kwargs ) + @payload('status') + def retweet(self, id, **kwargs): + """retweet(id, *, trim_user) + + Retweets a Tweet. Requires the ID of the Tweet you are retweeting. + + :param id: |sid| + :param trim_user: |trim_user| + + :rtype: :class:`Status` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-retweet-id + """ + return self.request( + 'POST', f'statuses/retweet/{id}', endpoint_parameters=( + 'trim_user', + ), **kwargs + ) + @payload('status') def update_status(self, status, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-update @@ -825,16 +844,6 @@ class API: ), command='STATUS', media_id=media_id, upload_api=True, **kwargs ) - @payload('status') - def retweet(self, id, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-retweet-id - """ - return self.request( - 'POST', f'statuses/retweet/{id}', endpoint_parameters=( - 'trim_user', - ), **kwargs - ) - @payload('status') def unretweet(self, id, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-unretweet-id