From f79959066994864408fd90143430d728c0dbe7ce Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 21 Jun 2019 00:05:33 -0500 Subject: [PATCH] Update API.destroy_direct_message --- docs/api.rst | 10 ++++++---- tweepy/api.py | 7 +++---- tweepy/binder.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 7ebaccc..260cbd3 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -287,11 +287,13 @@ Direct Message Methods .. method:: API.destroy_direct_message(id) - Destroy a direct message. Authenticating user must be the recipient of - the direct message. + Deletes the direct message specified in the required ID parameter. + The authenticating user must be the recipient of the specified direct message. + Direct Messages are only removed from the interface of the user context provided. + Other members of the conversation can still access the Direct Messages. - :param id: The ID of the direct message to destroy. - :rtype: :class:`DirectMessage` object + :param id: The id of the Direct Message that should be deleted. + :rtype: None Friendship Methods diff --git a/tweepy/api.py b/tweepy/api.py index cc2e3bd..49f2f36 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -459,14 +459,13 @@ class API(object): @property def destroy_direct_message(self): - """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/delete-message + """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/delete-message-event :allowed_param:'id' """ return bind_api( api=self, - path='/direct_messages/destroy.json', - method='POST', - payload_type='direct_message', + path='/direct_messages/events/destroy.json', + method='DELETE', allowed_param=['id'], require_auth=True ) diff --git a/tweepy/binder.py b/tweepy/binder.py index 20f961c..60b6b70 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -205,7 +205,7 @@ def bind_api(**config): continue retry_delay = self.retry_delay # Exit request loop if non-retry error code - if resp.status_code == 200: + if resp.status_code in (200, 204): break elif (resp.status_code == 429 or resp.status_code == 420) and self.wait_on_rate_limit: if 'retry-after' in resp.headers: -- 2.25.1