From 86337e330cf91db7b4b2c2faea87a517567697b5 Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 6 Apr 2021 18:50:16 -0500 Subject: [PATCH] Update and improve documentation for API.create_favorite Automatically use docstring for documentation Improve method and documentation order Add documentation for include_entities parameter Improve formatting and capitalization of reference --- docs/api.rst | 11 ++--------- tweepy/api.py | 30 ++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 64d9da0..3997d8b 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -45,6 +45,8 @@ Post, retrieve, and engage with Tweets .. automethod:: API.get_status +.. automethod:: API.create_favorite + Status methods -------------- @@ -444,15 +446,6 @@ Account Methods Favorite Methods ---------------- -.. method:: API.create_favorite(id) - - Favorites the status specified in the ID parameter as the authenticating - user. - - :param id: |sid| - :rtype: :class:`Status` object - - .. method:: API.destroy_favorite(id) Un-favorites the status specified in the ID parameter as the authenticating diff --git a/tweepy/api.py b/tweepy/api.py index e8219d5..38e9683 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -566,6 +566,26 @@ class API: ), id=id, **kwargs ) + @payload('status') + def create_favorite(self, id, **kwargs): + """create_favorite(id, *, include_entities) + + Favorites the status specified in the ``id`` parameter as the + authenticating user. + + :param id: |sid| + :param include_entities: |include_entities| + + :rtype: :class:`Status` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create + """ + return self.request( + 'POST', 'favorites/create', endpoint_parameters=( + 'id', 'include_entities' + ), id=id, **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 @@ -1082,16 +1102,6 @@ class API: ), **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 - """ - return self.request( - 'POST', 'favorites/create', endpoint_parameters=( - 'id', 'include_entities' - ), id=id, **kwargs - ) - @payload('status') def destroy_favorite(self, id, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-destroy -- 2.25.1