From 3aa6f1a8bb7685c7a2016fb659a63f90fb996b5c Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 10 Apr 2021 16:53:04 -0500 Subject: [PATCH] Update and improve documentation for API.get_direct_message Automatically use docstring for documentation Improve method order Remove full_text parameter from documentation Improve capitalization --- docs/api.rst | 9 +-------- tweepy/api.py | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 20d2295..f8975bf 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -199,14 +199,7 @@ Sending and receiving events .. automethod:: API.list_direct_messages - -.. method:: API.get_direct_message([id], [full_text]) - - Returns a specific direct message. - - :param id: The id of the Direct Message event that should be returned. - :param full_text: |full_text| - :rtype: :class:`DirectMessage` object +.. automethod:: API.get_direct_message .. method:: API.send_direct_message(recipient_id, text, [quick_reply_type], \ diff --git a/tweepy/api.py b/tweepy/api.py index b7d187f..6eafa25 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -2233,6 +2233,24 @@ class API: ), **kwargs ) + @payload('direct_message') + def get_direct_message(self, id, **kwargs): + """get_direct_message(id) + + Returns a specific direct message. + + :param id: The ID of the Direct Message event that should be returned. + + :rtype: :class:`DirectMessage` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/get-event + """ + return self.request( + 'GET', 'direct_messages/events/show', 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 @@ -2400,16 +2418,6 @@ class API: ), command='STATUS', media_id=media_id, upload_api=True, **kwargs ) - @payload('direct_message') - def get_direct_message(self, id, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/get-event - """ - return self.request( - 'GET', 'direct_messages/events/show', endpoint_parameters=( - 'id', - ), id=id, **kwargs - ) - @payload('direct_message') def send_direct_message(self, recipient_id, text, *, quick_reply_options=None, attachment_type=None, attachment_media_id=None, -- 2.25.1