From cf2d0ebc8246cea8c5e1dbb48687b625affe53c8 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Mon, 30 Jul 2018 16:20:56 +0200 Subject: Add follow suggestions --- docs/index.rst | 10 ++++++++++ mastodon/Mastodon.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index e90c342..6cb782e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -677,6 +677,11 @@ their relationships. .. automethod:: Mastodon.account_relationships .. automethod:: Mastodon.account_search +Reading data: Follow suggestions +-------------------------------- + +.. automethod:: Mastodon.suggestions + Reading data: Lists ------------------- These functions allow you to view information about lists. @@ -774,6 +779,11 @@ These functions allow you to interact with other accounts: To (un)follow and .. automethod:: Mastodon.account_unmute .. automethod:: Mastodon.account_update_credentials +Writing data: Follow suggestions +-------------------------------- + +.. automethod:: Mastodon.suggestion_delete + Writing data: Lists ------------------- These functions allow you to create, maintain and delete lists. diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 58380fd..5e73622 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -832,6 +832,19 @@ class Mastodon: url = '/api/v1/accounts/{0}/lists'.format(str(id)) return self.__api_request('GET', url, params) + ### + # Reading data: Follow suggestions + ### + @api_version("2.4.3", "2.4.3", __DICT_VERSION_ACCOUNT) + def suggestions(self): + """ + Fetch follow suggestions for the logged-in user. + + Returns a list of `user dicts`_. + + """ + return self.__api_request('GET', '/api/v1/suggestions') + ### # Reading data: Searching ### @@ -867,8 +880,11 @@ class Mastodon: """ Fetch trending-hashtag information, if the instance provides such information. + Does not require authentication. + Returns a list of `hashtag dicts`_, sorted by the instances trending algorithm, descending. + """ return self.__api_request('GET', '/api/v1/trends') @@ -1452,6 +1468,19 @@ class Mastodon: params = self.__generate_params(params_initial) return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params, files=files) + + ### + # Writing data: Follow suggestions + ### + @api_version("2.4.3", "2.4.3", __DICT_VERSION_ACCOUNT) + def suggestion_delete(self, account_id): + """ + Remove a single user from the follow suggestions. + """ + account_id = self.__unpack_id(account_id) + url = '/api/v1/suggestions/{0}'.format(str(account_id)) + self.__api_request('DELETE', url) + ### # Writing data: Lists ### -- cgit v1.2.3