From 669706b0ec22ec994f7831266ec081c5f63d1f3a Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 7 Apr 2021 08:31:39 -0500 Subject: [PATCH] Update and improve documentation for API.destroy_status Automatically use docstring for documentation Improve method and documentation order Add documentation for trim_user parameter Improve formatting --- 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 82b6670..dcd9368 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -49,6 +49,8 @@ Post, retrieve, and engage with Tweets .. automethod:: API.destroy_favorite +.. automethod:: API.destroy_status + Status methods -------------- @@ -151,15 +153,6 @@ Status methods :rtype: :class:`Status` object -.. method:: API.destroy_status(id) - - Destroy the status specified by the id parameter. The authenticated user - must be the author of the status to destroy. - - :param id: |sid| - :rtype: :class:`Status` object - - .. method:: API.retweet(id) Retweets a tweet. Requires the id of the tweet you are retweeting. diff --git a/tweepy/api.py b/tweepy/api.py index a5972fa..9ca0a12 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -606,6 +606,26 @@ class API: ), id=id, **kwargs ) + @payload('status') + def destroy_status(self, id, **kwargs): + """destroy_status(id, *, trim_user) + + Destroy the status specified by the ``id`` parameter. The authenticated + user must be the author of the status to destroy. + + :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-destroy-id + """ + return self.request( + 'POST', f'statuses/destroy/{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 @@ -805,16 +825,6 @@ class API: ), command='STATUS', media_id=media_id, upload_api=True, **kwargs ) - @payload('status') - def destroy_status(self, id, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-destroy-id - """ - return self.request( - 'POST', f'statuses/destroy/{id}', endpoint_parameters=( - 'trim_user', - ), **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 -- 2.25.1