Replace API.direct_messages and API.sent_direct_messages
authorHarmon <Harmon758@gmail.com>
Fri, 21 Jun 2019 01:54:37 +0000 (20:54 -0500)
committerHarmon <Harmon758@gmail.com>
Fri, 21 Jun 2019 16:42:10 +0000 (11:42 -0500)
With API.list_direct_messages

docs/api.rst
tests/test_api.py
tweepy/api.py

index f0144ae42020180ecf21c870c7d920c280ecb006..afefb437d28f66db9f56dfbef527f72f81b44352 100644 (file)
@@ -249,18 +249,6 @@ User methods
 Direct Message Methods
 ----------------------
 
-.. method:: API.direct_messages([since_id], [max_id], [count], [page], [full_text])
-
-   Returns direct messages sent to the authenticating user.
-
-   :param since_id: |since_id|
-   :param max_id: |max_id|
-   :param count: |count|
-   :param page: |page|
-   :param full_text: |full_text|
-   :rtype: list of :class:`DirectMessage` objects
-
-
 .. method:: API.get_direct_message([id], [full_text])
 
    Returns a specific direct message.
@@ -270,15 +258,13 @@ Direct Message Methods
    :rtype: :class:`DirectMessage` object
 
 
-.. method:: API.sent_direct_messages([since_id], [max_id], [count], [page], [full_text])
+.. method:: API.list_direct_messages([count], [cursor])
 
-   Returns direct messages sent by the authenticating user.
+   Returns all Direct Message events (both sent and received)
+   within the last 30 days. Sorted in reverse-chronological order.
 
-   :param since_id: |since_id|
-   :param max_id: |max_id|
    :param count: |count|
-   :param page: |page|
-   :param full_text: |full_text|
+   :param cursor: |cursor|
    :rtype: list of :class:`DirectMessage` objects
 
 
index e057c4421d67fba225d40c67163935d7376015c0..92ca6d49444a5b08550c943a4bcf5711be7193cf 100644 (file)
@@ -154,13 +154,9 @@ class TweepyAPITests(TweepyTestCase):
         me = self.api.me()
         self.assertEqual(me.screen_name, username)
 
-    @tape.use_cassette('testdirectmessages.json')
-    def testdirectmessages(self):
-        self.api.direct_messages()
-
-    @tape.use_cassette('testsentdirectmessages.json')
-    def testsentdirectmessages(self):
-        self.api.sent_direct_messages()
+    @tape.use_cassette('testlistdirectmessages.json')
+    def testlistdirectmessages(self):
+        self.api.list_direct_messages()
 
     @tape.use_cassette('testsendanddestroydirectmessage.json')
     def testsendanddestroydirectmessage(self):
index 48b22536bb45dbd39d0a8be0bc3ffdd86e210584..b842de12489729e67e6b2a5692b9a062464569c3 100644 (file)
@@ -405,19 +405,6 @@ class API(object):
             require_auth=True
         )
 
-    @property
-    def direct_messages(self):
-        """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-messages
-            :allowed_param:'since_id', 'max_id', 'count', 'full_text'
-        """
-        return bind_api(
-            api=self,
-            path='/direct_messages.json',
-            payload_type='direct_message', payload_list=True,
-            allowed_param=['since_id', 'max_id', 'count', 'full_text'],
-            require_auth=True
-        )
-
     @property
     def get_direct_message(self):
         """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-message
@@ -432,15 +419,15 @@ class API(object):
         )
 
     @property
-    def sent_direct_messages(self):
-        """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-sent-message
-            :allowed_param:'since_id', 'max_id', 'count', 'page', 'full_text'
+    def list_direct_messages(self):
+        """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/list-events
+            :allowed_param:'count', 'cursor'
         """
         return bind_api(
             api=self,
-            path='/direct_messages/sent.json',
+            path='/direct_messages/events/list.json',
             payload_type='direct_message', payload_list=True,
-            allowed_param=['since_id', 'max_id', 'count', 'page', 'full_text'],
+            allowed_param=['count', 'cursor'],
             require_auth=True
         )