From 72e3290d8c9ed1dc0babf66ef70a6835a0dcacf4 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Sat, 27 Apr 2019 22:13:27 +0200 Subject: Add endorsements (with docs and tests) --- mastodon/Mastodon.py | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'mastodon') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index d272a33..ca7dbd6 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -923,6 +923,20 @@ class Mastodon: """ return self.__api_request('GET', '/api/v1/suggestions') + ### + # Reading data: Endorsements + ### + @api_version("2.5.0", "2.5.0", __DICT_VERSION_ACCOUNT) + def endorsements(self): + """ + Fetch list of users endorsemed by the logged-in user. + + Returns a list of `user dicts`_. + + """ + return self.__api_request('GET', '/api/v1/endorsements') + + ### # Reading data: Searching ### @@ -1463,8 +1477,9 @@ class Mastodon: Returns a `relationship dict`_ containing the updated relationship to the user. """ id = self.__unpack_id(id) + params = self.__generate_params(locals(), ['id']) url = '/api/v1/accounts/{0}/mute'.format(str(id)) - return self.__api_request('POST', url) + return self.__api_request('POST', url, params) @api_version("1.1.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) def account_unmute(self, id): @@ -1545,6 +1560,28 @@ class Mastodon: return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params, files=files) + @api_version("2.5.0", "2.5.0", __DICT_VERSION_RELATIONSHIP) + def account_pin(self, id): + """ + Pin / endorse a user. + + Returns a `relationship dict`_ containing the updated relationship to the user. + """ + id = self.__unpack_id(id) + url = '/api/v1/accounts/{0}/pin'.format(str(id)) + return self.__api_request('POST', url) + + @api_version("2.5.0", "2.5.0", __DICT_VERSION_RELATIONSHIP) + def account_unpin(self, id): + """ + Unpin / un-endorse a user. + + Returns a `relationship dict`_ containing the updated relationship to the user. + """ + id = self.__unpack_id(id) + url = '/api/v1/accounts/{0}/unpin'.format(str(id)) + return self.__api_request('POST', url) + ### # Writing data: Keyword filters ### -- cgit v1.2.3