From 207b38ba1a653b50b5b4ff0456a211701ec301ac Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 6 Apr 2021 17:11:05 -0500 Subject: [PATCH] Update and improve documentation for API.favorites Automatically use docstring for documentation Improve method and documentation order Add user_id, screen_name, count, since_id, max_id, and include_entities parameters to documentation Remove id and page parameters from documentation --- docs/api.rst | 12 ++---------- tweepy/api.py | 39 +++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 9c794e4..7f71f9e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -28,6 +28,8 @@ Get Tweet timelines Post, retrieve, and engage with Tweets -------------------------------------- +.. automethod:: API.favorites + .. method:: API.statuses_lookup(id_, [include_entities], [trim_user], [map_], \ [include_ext_alt_text], [include_card_uri]) @@ -554,16 +556,6 @@ Account Methods Favorite Methods ---------------- -.. method:: API.favorites([id], [page]) - - Returns the favorite statuses for the authenticating user or user specified - by the ID parameter. - - :param id: The ID or screen name of the user to request favorites - :param page: |page| - :rtype: list of :class:`Status` objects - - .. method:: API.create_favorite(id) Favorites the status specified in the ID parameter as the authenticating diff --git a/tweepy/api.py b/tweepy/api.py index 96470cc..8b6d00a 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -342,6 +342,33 @@ class API: # Post, retrieve, and engage with Tweets + @pagination(mode='id') + @payload('status', list=True) + def favorites(self, **kwargs): + """favorites(*, user_id, screen_name, count, since_id, max_id, \ + include_entities) + + Returns the favorite statuses for the authenticating user or user + specified by the ID parameter. + + :param user_id: |user_id| + :param screen_name: |screen_name| + :param count: |count| + :param since_id: |since_id| + :param max_id: |max_id| + :param include_entities: |include_entities| + + :rtype: list of :class:`Status` objects + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-favorites-list + """ + return self.request( + 'GET', 'favorites/list', endpoint_parameters=( + 'user_id', 'screen_name', 'count', 'since_id', 'max_id', + 'include_entities' + ), **kwargs + ) + @payload('status', list=True) def statuses_lookup(self, id, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-lookup @@ -925,18 +952,6 @@ class API: ), **kwargs ) - @pagination(mode='id') - @payload('status', list=True) - def favorites(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-favorites-list - """ - return self.request( - 'GET', 'favorites/list', endpoint_parameters=( - 'user_id', 'screen_name', 'count', 'since_id', 'max_id', - 'include_entities' - ), **kwargs - ) - @payload('status') def create_favorite(self, id, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create -- 2.25.1