diff options
Diffstat (limited to 'mastodon/hashtags.py')
-rw-r--r-- | mastodon/hashtags.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/mastodon/hashtags.py b/mastodon/hashtags.py new file mode 100644 index 0000000..89e8cac --- /dev/null +++ b/mastodon/hashtags.py | |||
@@ -0,0 +1,52 @@ | |||
1 | # hashtags.py - hashtag and featured-hashtag endpoints | ||
2 | |||
3 | from .versions import _DICT_VERSION_FEATURED_TAG, _DICT_VERSION_HASHTAG | ||
4 | from .utility import api_version | ||
5 | |||
6 | from .internals import Mastodon as Internals | ||
7 | |||
8 | class Mastodon(Internals): | ||
9 | ### | ||
10 | # Reading data: Featured hashtags | ||
11 | ### | ||
12 | @api_version("3.0.0", "3.0.0", _DICT_VERSION_FEATURED_TAG) | ||
13 | def featured_tags(self): | ||
14 | """ | ||
15 | Return the hashtags the logged-in user has set to be featured on | ||
16 | their profile as a list of :ref:`featured tag dicts <featured tag dicts>`. | ||
17 | |||
18 | Returns a list of :ref:`featured tag dicts <featured tag dicts>`. | ||
19 | """ | ||
20 | return self.__api_request('GET', '/api/v1/featured_tags') | ||
21 | |||
22 | @api_version("3.0.0", "3.0.0", _DICT_VERSION_HASHTAG) | ||
23 | def featured_tag_suggestions(self): | ||
24 | """ | ||
25 | Returns the logged-in user's 10 most commonly-used hashtags. | ||
26 | |||
27 | Returns a list of :ref:`hashtag dicts <hashtag dicts>`. | ||
28 | """ | ||
29 | return self.__api_request('GET', '/api/v1/featured_tags/suggestions') | ||
30 | |||
31 | ### | ||
32 | # Writing data: Featured hashtags | ||
33 | ### | ||
34 | @api_version("3.0.0", "3.0.0", _DICT_VERSION_FEATURED_TAG) | ||
35 | def featured_tag_create(self, name): | ||
36 | """ | ||
37 | Creates a new featured hashtag displayed on the logged-in user's profile. | ||
38 | |||
39 | Returns a :ref:`featured tag dict <featured tag dict>` with the newly featured tag. | ||
40 | """ | ||
41 | params = self.__generate_params(locals()) | ||
42 | return self.__api_request('POST', '/api/v1/featured_tags', params) | ||
43 | |||
44 | @api_version("3.0.0", "3.0.0", _DICT_VERSION_FEATURED_TAG) | ||
45 | def featured_tag_delete(self, id): | ||
46 | """ | ||
47 | Deletes one of the logged-in user's featured hashtags. | ||
48 | """ | ||
49 | id = self.__unpack_id(id) | ||
50 | url = '/api/v1/featured_tags/{0}'.format(str(id)) | ||
51 | self.__api_request('DELETE', url) | ||
52 | \ No newline at end of file | ||