From a5df61561f2f40be88bc0e52bb6e50ce7b6a6052 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 10 Apr 2021 09:22:17 -0500 Subject: [PATCH] Document API.update_profile_banner Automatically use docstring for documentation Improve method order --- docs/api.rst | 2 ++ tweepy/api.py | 46 +++++++++++++++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 336f087..2419d07 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -160,6 +160,8 @@ Manage account settings and profile .. automethod:: API.update_profile +.. automethod:: API.update_profile_banner + Direct Message Methods ---------------------- diff --git a/tweepy/api.py b/tweepy/api.py index 9d04926..91b36c2 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1912,6 +1912,39 @@ class API: ), **kwargs ) + def update_profile_banner(self, filename, *, file=None, **kwargs): + """update_profile_banner(filename, *, file, width, height, \ + offset_left, offset_top) + + Uploads a profile banner on behalf of the authenticating user. + + :param filename: |filename| + :param file: |file| + :param width: The width of the preferred section of the image being + uploaded in pixels. Use with ``height``, ``offset_left``, and + ``offset_top`` to select the desired region of the image to use. + :param height: The height of the preferred section of the image being + uploaded in pixels. Use with ``width``, ``offset_left``, and + ``offset_top`` to select the desired region of the image to use. + :param offset_left: The number of pixels by which to offset the + uploaded image from the left. Use with ``height``, ``width``, and + ``offset_top`` to select the desired region of the image to use. + :param offset_top: The number of pixels by which to offset the uploaded + image from the top. Use with ``height``, ``width``, and + ``offset_left`` to select the desired region of the image to use. + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_banner + """ + if file is not None: + files = {'banner': (filename, file)} + else: + files = {'banner': open(filename, 'rb')} + return self.request( + 'POST', 'account/update_profile_banner', endpoint_parameters=( + 'width', 'height', 'offset_left', 'offset_right' + ), files=files, **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 @@ -2165,19 +2198,6 @@ class API: ), files=files, **kwargs ) - def update_profile_banner(self, filename, *, file=None, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_banner - """ - if file is not None: - files = {'banner': (filename, file)} - else: - files = {'banner': open(filename, 'rb')} - return self.request( - 'POST', 'account/update_profile_banner', endpoint_parameters=( - 'width', 'height', 'offset_left', 'offset_right' - ), files=files, **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 -- 2.25.1