From 0b5c0ae5ccb61a42ed19ee9c5b46de65979b9060 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Wed, 13 Dec 2017 22:16:10 +0100 Subject: Add remaining list endpoints --- mastodon/.Mastodon.py.kate-swp | Bin 0 -> 106 bytes mastodon/Mastodon.py | 61 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 mastodon/.Mastodon.py.kate-swp diff --git a/mastodon/.Mastodon.py.kate-swp b/mastodon/.Mastodon.py.kate-swp new file mode 100644 index 0000000..60f8d57 Binary files /dev/null and b/mastodon/.Mastodon.py.kate-swp differ diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 44e0538..3b02881 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -666,6 +666,25 @@ class Mastodon: id = self.__unpack_id(id) return self.__api_request('GET', '/api/v1/lists/{0}'.format(id)) + @api_version("2.1.0") + def list_accounts(self, id, max_id=None, since_id=None, limit=None): + """ + Get the accounts that are on the given list. A `limit` of 0 can + be specified to get all accounts without pagination. + + Returns a list of `user dicts`_. + """ + id = self.__unpack_id(id) + + if max_id != None: + max_id = self.__unpack_id(max_id) + + if since_id != None: + since_id = self.__unpack_id(since_id) + + params = self.__generate_params(locals(), ['id']) + return self.__api_request('GET', '/api/v1/lists/{0}/accounts'.format(id)) + ### # Reading data: Mutes and Blocks ### @@ -1086,6 +1105,42 @@ class Mastodon: id = self.__unpack_id(id) self.__api_request('DELETE', '/api/v1/lists/{0}'.format(id)) + @api_version("2.1.0") + def list_delete(self, id): + """ + Delete a list. + """ + id = self.__unpack_id(id) + self.__api_request('DELETE', '/api/v1/lists/{0}'.format(id)) + + @api_version("2.1.0") + def list_accounts_add(self, id, account_ids): + """ + Add the account(s) given in `account_ids` to the list. + """ + id = self.__unpack_id(id) + + if not isinstance(account_ids, list): + account_ids = [account_ids] + account_ids = list(map(lambda x: self.__unpack_id(x), account_ids)) + + params = self.__generate_params(locals(), ['id']) + return self.__api_request('POST', '/api/v1/lists/{0}/accounts'.format(id), params) + + @api_version("2.1.0") + def list_accounts_delete(self, id, account_ids): + """ + Remove the account(s) given in `account_ids` from the list. + """ + id = self.__unpack_id(id) + + if not isinstance(account_ids, list): + account_ids = [account_ids] + account_ids = list(map(lambda x: self.__unpack_id(x), account_ids)) + + params = self.__generate_params(locals(), ['id']) + return self.__api_request('DELETE', '/api/v1/lists/{0}/accounts'.format(id), params) + ### # Writing data: Reports ### @@ -1099,7 +1154,11 @@ class Mastodon: Returns a `report dict`_. """ account_id = self.__unpack_id(account_id) - status_ids = map(lambda x: self.__unpack_id(x), status_ids) + + if not isinstance(status_ids, list): + status_ids = [status_ids] + status_ids = list(map(lambda x: self.__unpack_id(x), status_ids)) + params = self.__generate_params(locals()) return self.__api_request('POST', '/api/v1/reports/', params) -- cgit v1.2.3