From 4df0247600d9b5bba948885e3062e6896af1a617 Mon Sep 17 00:00:00 2001 From: Harmon Date: Thu, 20 Jun 2019 20:54:37 -0500 Subject: [PATCH] Replace API.direct_messages and API.sent_direct_messages With API.list_direct_messages --- docs/api.rst | 22 ++++------------------ tests/test_api.py | 10 +++------- tweepy/api.py | 23 +++++------------------ 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index f0144ae..afefb43 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -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 diff --git a/tests/test_api.py b/tests/test_api.py index e057c44..92ca6d4 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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): diff --git a/tweepy/api.py b/tweepy/api.py index 48b2253..b842de1 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -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 ) -- 2.25.1