From c9ffa0218c2908b0085814b92e7019db805ea1b8 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 10 Apr 2021 10:27:06 -0500 Subject: [PATCH] Update and improve documentation for API.report_spam Automatically use docstring for documentation Improve method and documentation order Remove id parameter from documentation Update method/endpoint documentation --- docs/api.rst | 18 ++---------------- tweepy/api.py | 31 +++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 92e15da..ffb5391 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -187,6 +187,8 @@ Mute, block, and report users .. automethod:: API.destroy_mute +.. automethod:: API.report_spam + Direct Message Methods ---------------------- @@ -258,22 +260,6 @@ Account Methods :rtype: :class:`JSON` object -Spam Reporting Methods ----------------------- - -.. method:: API.report_spam(id/screen_name/user_id, [perform_block]) - - The user specified in the id is blocked by the authenticated user and - reported as a spammer. - - :param id: |uid| - :param screen_name: |screen_name| - :param user_id: |user_id| - :param perform_block: A boolean indicating if the reported account should be - blocked. Defaults to True. - :rtype: :class:`User` object - - Search Methods -------------- diff --git a/tweepy/api.py b/tweepy/api.py index ac63bab..138cbc7 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -2178,6 +2178,27 @@ class API: ), **kwargs ) + @payload('user') + def report_spam(self, **kwargs): + """report_spam(*, screen_name, user_id, perform_block) + + Report the specified user as a spam account to Twitter. + + :param screen_name: |screen_name| + :param user_id: |user_id| + :param perform_block: A boolean indicating if the reported account + should be blocked. Defaults to True. + + :rtype: :class:`User` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-users-report_spam + """ + return self.request( + 'POST', 'users/report_spam', endpoint_parameters=( + 'screen_name', 'user_id', 'perform_block' + ), **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 @@ -2417,16 +2438,6 @@ class API: ), use_cache=False, **kwargs ) - @payload('user') - def report_spam(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-users-report_spam - """ - return self.request( - 'POST', 'users/report_spam', endpoint_parameters=( - 'screen_name', 'user_id', 'perform_block' - ), **kwargs - ) - @payload('json') def trends_available(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/trends/locations-with-trending-topics/api-reference/get-trends-available -- 2.25.1