From: Harmon Date: Sat, 10 Apr 2021 21:48:43 +0000 (-0500) Subject: Update and improve documentation for API.list_direct_messages X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=91f3cf1d166e359075253aac0f16f734dfeb3d65;p=tweepy.git Update and improve documentation for API.list_direct_messages Automatically use docstring for documentation Improve method and documentation order --- diff --git a/docs/api.rst b/docs/api.rst index 83cfaf4..20d2295 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -197,6 +197,8 @@ Sending and receiving events .. automethod:: API.destroy_direct_message +.. automethod:: API.list_direct_messages + .. method:: API.get_direct_message([id], [full_text]) @@ -207,16 +209,6 @@ Sending and receiving events :rtype: :class:`DirectMessage` object -.. method:: API.list_direct_messages([count], [cursor]) - - Returns all Direct Message events (both sent and received) within the last - 30 days. Sorted in reverse-chronological order. - - :param count: |count| - :param cursor: |cursor| - :rtype: list of :class:`DirectMessage` objects - - .. method:: API.send_direct_message(recipient_id, text, [quick_reply_type], \ [attachment_type], [attachment_media_id]) diff --git a/tweepy/api.py b/tweepy/api.py index dd77d58..b7d187f 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -2212,6 +2212,27 @@ class API: ), id=id, **kwargs ) + @pagination(mode='dm_cursor') + @payload('direct_message', list=True) + def list_direct_messages(self, **kwargs): + """list_direct_messages(*, count, cursor) + + Returns all Direct Message events (both sent and received) within the + last 30 days. Sorted in reverse-chronological order. + + :param count: |count| + :param cursor: |cursor| + + :rtype: list of :class:`DirectMessage` objects + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/list-events + """ + return self.request( + 'GET', 'direct_messages/events/list', endpoint_parameters=( + 'count', 'cursor' + ), **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 @@ -2389,17 +2410,6 @@ class API: ), id=id, **kwargs ) - @pagination(mode='dm_cursor') - @payload('direct_message', list=True) - def list_direct_messages(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/list-events - """ - return self.request( - 'GET', 'direct_messages/events/list', endpoint_parameters=( - 'count', 'cursor' - ), **kwargs - ) - @payload('direct_message') def send_direct_message(self, recipient_id, text, *, quick_reply_options=None, attachment_type=None, attachment_media_id=None,