From 4703da38090292fb48d4d6853eb67883a5c282b8 Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 9 Apr 2021 15:26:43 -0500 Subject: [PATCH] Document API.set_settings Automatically use docstring for documentation Improve method order --- docs/api.rst | 2 ++ tweepy/api.py | 53 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 852ad1e..f984bb1 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -156,6 +156,8 @@ Manage account settings and profile .. automethod:: API.remove_profile_banner +.. automethod:: API.set_settings + Direct Message Methods ---------------------- diff --git a/tweepy/api.py b/tweepy/api.py index a12c510..4ce4aab 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1837,6 +1837,48 @@ class API: """ return self.request('POST', 'account/remove_profile_banner', **kwargs) + @payload('json') + def set_settings(self, **kwargs): + """set_settings(*, sleep_time_enabled, start_sleep_time, \ + end_sleep_time, time_zone, trend_location_woeid, lang) + + Updates the authenticating user's settings. + + :param sleep_time_enabled: When set to ``true``, ``t`` or ``1`` , will + enable sleep time for the user. Sleep time is the time when push or + SMS notifications should not be sent to the user. + :param start_sleep_time: The hour that sleep time should begin if it is + enabled. The value for this parameter should be provided in + `ISO 8601`_ format (i.e. 00-23). The time is considered to be in + the same timezone as the user's ``time_zone`` setting. + :param end_sleep_time: The hour that sleep time should end if it is + enabled. The value for this parameter should be provided in + `ISO 8601`_ format (i.e. 00-23). The time is considered to be in + the same timezone as the user's ``time_zone`` setting. + :param time_zone: The timezone dates and times should be displayed in + for the user. The timezone must be one of the `Rails TimeZone`_ + names. + :param trend_location_woeid: The Yahoo! Where On Earth ID to use as the + user's default trend location. Global information is available by + using 1 as the WOEID. + :param lang: The language which Twitter should render in for this user. + The language must be specified by the appropriate two letter ISO + 639-1 representation. + + :rtype: :class:`JSON` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-settings + + .. _ISO 8601: https://en.wikipedia.org/wiki/ISO_8601 + .. _Rails TimeZone: https://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html + """ + return self.request( + 'POST', 'account/settings', endpoint_parameters=( + 'sleep_time_enabled', 'start_sleep_time', 'end_sleep_time', + 'time_zone', 'trend_location_woeid', 'lang' + ), use_cache=False, **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 @@ -2066,17 +2108,6 @@ class API: ), id=id, **kwargs ) - @payload('json') - def set_settings(self, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-settings - """ - return self.request( - 'POST', 'account/settings', endpoint_parameters=( - 'sleep_time_enabled', 'start_sleep_time', 'end_sleep_time', - 'time_zone', 'trend_location_woeid', 'lang' - ), use_cache=False, **kwargs - ) - @payload('json') def rate_limit_status(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status -- 2.25.1