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.
: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
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):
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
)
@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
)