From: Harmon Date: Tue, 6 Apr 2021 23:17:57 +0000 (-0500) Subject: Update and improve documentation for API.retweets X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e1e518f1bd105f28e35fa49673aff6c88de192fe;p=tweepy.git Update and improve documentation for API.retweets Automatically use docstring for documentation Improve method and documentation order Add documentation for trim_user parameter Use substitution for count parameter documentation Improve capitalization --- diff --git a/docs/api.rst b/docs/api.rst index ef35b96..45d19bd 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -39,6 +39,8 @@ Post, retrieve, and engage with Tweets .. automethod:: API.retweeters +.. automethod:: API.retweets + .. method:: API.retweets_of_me([since_id], [max_id], [count], [page]) Returns the 20 most recent tweets of the authenticated user that have been @@ -187,15 +189,6 @@ Status methods :rtype: :class:`Status` object -.. method:: API.retweets(id, [count]) - - Returns up to 100 of the first retweets of the given tweet. - - :param id: |sid| - :param count: Specifies the number of retweets to retrieve. - :rtype: list of :class:`Status` objects - - .. 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 895282a..9e2af5a 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -491,6 +491,26 @@ class API: ), id=id, **kwargs ) + @payload('status', list=True) + def retweets(self, id, **kwargs): + """retweets(id, *, count, trim_user) + + Returns up to 100 of the first Retweets of the given Tweet. + + :param id: |sid| + :param count: |count| + :param trim_user: |trim_user| + + :rtype: list of :class:`Status` objects + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-retweets-id + """ + return self.request( + 'GET', f'statuses/retweets/{id}', endpoint_parameters=( + 'count', 'trim_user' + ), **kwargs + ) + @pagination(mode='id') @payload('status', list=True) def retweets_of_me(self, **kwargs): @@ -743,16 +763,6 @@ class API: ), **kwargs ) - @payload('status', list=True) - def retweets(self, id, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-retweets-id - """ - return self.request( - 'GET', f'statuses/retweets/{id}', endpoint_parameters=( - 'count', 'trim_user' - ), **kwargs - ) - @payload('user') def get_user(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-users-show