From e7472f880bc1b1c621eca8d3a98d6946ddba4af0 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 10 Apr 2021 16:46:50 -0500 Subject: [PATCH] Update and improve documentation for API.destroy_direct_message Automatically use docstring for documentation Improve method and documentation order Add and update API documentation headers to match API reference index Improve capitalization --- docs/api.rst | 21 +++++++-------------- tweepy/api.py | 32 +++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index ffb5391..83cfaf4 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -189,9 +189,14 @@ Mute, block, and report users .. automethod:: API.report_spam +Direct Messages +--------------- + +Sending and receiving events +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automethod:: API.destroy_direct_message -Direct Message Methods ----------------------- .. method:: API.get_direct_message([id], [full_text]) @@ -234,18 +239,6 @@ Direct Message Methods :rtype: :class:`DirectMessage` object -.. method:: API.destroy_direct_message(id) - - Deletes the direct message specified in the required ID parameter. The - authenticating user must be the recipient of the specified direct message. - Direct Messages are only removed from the interface of the user context - provided. Other members of the conversation can still access the Direct - Messages. - - :param id: The id of the Direct Message that should be deleted. - :rtype: None - - Account Methods --------------- diff --git a/tweepy/api.py b/tweepy/api.py index c008118..dd77d58 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -2189,6 +2189,29 @@ class API: ), **kwargs ) + # Sending and receiving events + + def destroy_direct_message(self, id, **kwargs): + """destroy_direct_message(id) + + Deletes the direct message specified in the required ID parameter. The + authenticating user must be the recipient of the specified direct + message. Direct Messages are only removed from the interface of the + user context provided. Other members of the conversation can still + access the Direct Messages. + + :param id: The ID of the Direct Message that should be deleted. + + :rtype: None + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/delete-message-event + """ + return self.request( + 'DELETE', 'direct_messages/events/destroy', endpoint_parameters=( + 'id', + ), id=id, **kwargs + ) + def media_upload(self, filename, *, file=None, chunked=False, media_category=None, additional_owners=None, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview @@ -2409,15 +2432,6 @@ class API: json_payload=json_payload, **kwargs ) - def destroy_direct_message(self, id, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/delete-message-event - """ - return self.request( - 'DELETE', 'direct_messages/events/destroy', endpoint_parameters=( - 'id', - ), id=id, **kwargs - ) - @payload('json') def rate_limit_status(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status -- 2.25.1