Update and improve documentation for API.list_direct_messages
authorHarmon <Harmon758@gmail.com>
Sat, 10 Apr 2021 21:48:43 +0000 (16:48 -0500)
committerHarmon <Harmon758@gmail.com>
Sat, 10 Apr 2021 21:48:43 +0000 (16:48 -0500)
Automatically use docstring for documentation
Improve method and documentation order

docs/api.rst
tweepy/api.py

index 83cfaf4dd1d4b07103ab5c9ba1141360c1d5308f..20d2295de1b49adaf607e641ecf1b45f7a51ad2e 100644 (file)
@@ -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])
 
index dd77d58c5d0372f75d4b04080e6f9aa470058b71..b7d187fab680eb03e77e7a2d6aaac8e8f902be0d 100644 (file)
@@ -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,