From 7833cbecaab105848d058094cce2c86c1cd9a1e1 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 10 Apr 2021 10:13:16 -0500 Subject: [PATCH] Update and improve documentation for API.create_block Automatically use docstring for documentation Improve method and documentation order Add include_entities and skip_status parameters to documentation Remove id parameter from documentation Update method/endpoint documentation --- docs/api.rst | 13 ++----------- tweepy/api.py | 34 ++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 7c76c67..96141ce 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -179,6 +179,8 @@ Mute, block, and report users .. automethod:: API.mutes +.. automethod:: API.create_block + Direct Message Methods ---------------------- @@ -253,17 +255,6 @@ Account Methods Block Methods ------------- -.. method:: API.create_block(id/screen_name/user_id) - - Blocks the user specified in the ID parameter as the authenticating user. - Destroys a friendship to the blocked user if it exists. - - :param id: |uid| - :param screen_name: |screen_name| - :param user_id: |user_id| - :rtype: :class:`User` object - - .. method:: API.destroy_block(id/screen_name/user_id) Un-blocks the user specified in the ID parameter for the authenticating diff --git a/tweepy/api.py b/tweepy/api.py index 380923d..b543e54 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -2091,6 +2091,30 @@ class API: ), **kwargs ) + @payload('user') + def create_block(self, **kwargs): + """create_block(*, screen_name, user_id, include_entities, skip_status) + + Blocks the specified user from following the authenticating user. In + addition the blocked user will not show in the authenticating users + mentions or timeline (unless retweeted by another user). If a follow or + friend relationship exists it is destroyed. + + :param screen_name: |screen_name| + :param user_id: |user_id| + :param include_entities: |include_entities| + :param skip_status: |skip_status| + + :rtype: :class:`User` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create + """ + return self.request( + 'POST', 'blocks/create', endpoint_parameters=( + 'screen_name', 'user_id', 'include_entities', 'skip_status' + ), **kwargs + ) + def media_upload(self, filename, *, file=None, chunked=False, media_category=None, additional_owners=None, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview @@ -2330,16 +2354,6 @@ class API: ), use_cache=False, **kwargs ) - @payload('user') - def create_block(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create - """ - return self.request( - 'POST', 'blocks/create', endpoint_parameters=( - 'screen_name', 'user_id', 'include_entities', 'skip_status' - ), **kwargs - ) - @payload('user') def destroy_block(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-destroy -- 2.25.1