Skip to content

Commit 402bd8c

Browse files
committed
feat(dm): ✨ Add support for the DM block API
1 parent 4a0885a commit 402bd8c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pytwitter/api.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,34 @@ def unblock_user(self, user_id: str, target_user_id: str) -> dict:
20352035
data = self._parse_response(resp)
20362036
return data
20372037

2038+
def block_user_dm(self, target_user_id: str):
2039+
"""
2040+
Allows the authenticated user to block direct messages (DMs) from the target user.
2041+
:param target_user_id: target user id
2042+
:return: blocked status
2043+
"""
2044+
resp = self._request(
2045+
url=f"{self.BASE_URL_V2}/users/{target_user_id}/dm/block",
2046+
verb="POST",
2047+
)
2048+
data = self._parse_response(resp)
2049+
return data
2050+
2051+
2052+
def unblock_user_dm(self, target_user_id: str):
2053+
"""
2054+
Allows the authenticated user to unblock direct messages (DMs) from the target user.
2055+
:param target_user_id: target user id
2056+
:return: unblocked status
2057+
"""
2058+
resp = self._request(
2059+
url=f"{self.BASE_URL_V2}/users/{target_user_id}/dm/unblock",
2060+
verb="POST",
2061+
)
2062+
data = self._parse_response(resp)
2063+
return data
2064+
2065+
20382066
def get_user_muting(
20392067
self,
20402068
user_id: str,

0 commit comments

Comments
 (0)