aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-10-12 21:47:58 +0200
committerLorenz Diener <[email protected]>2019-10-12 21:47:58 +0200
commit63bf5afc61503ebd99a7e7bc36014b378db98d23 (patch)
treeb66daf9ec0727cd0c59a9ca8146958d74b508ea3 /mastodon
parent3194b1295e8f4a6d151d18ad4f23174c63408c05 (diff)
downloadmastodon.py-63bf5afc61503ebd99a7e7bc36014b378db98d23.tar.gz
Implement, test and document featured and suggested tags APIs (fixes #191)
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 899aae4..9c6f1ce 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -212,6 +212,7 @@ class Mastodon:
212 __DICT_VERSION_SCHEDULED_STATUS = bigger_version("2.7.0", __DICT_VERSION_STATUS) 212 __DICT_VERSION_SCHEDULED_STATUS = bigger_version("2.7.0", __DICT_VERSION_STATUS)
213 __DICT_VERSION_PREFERENCES = "2.8.0" 213 __DICT_VERSION_PREFERENCES = "2.8.0"
214 __DICT_VERSION_ADMIN_ACCOUNT = "2.9.1" 214 __DICT_VERSION_ADMIN_ACCOUNT = "2.9.1"
215 __DICT_VERSION_FEATURED_TAG = "3.0.0"
215 216
216 ### 217 ###
217 # Registering apps 218 # Registering apps
@@ -1145,6 +1146,28 @@ class Mastodon:
1145 return self.__api_request('GET', url, params) 1146 return self.__api_request('GET', url, params)
1146 1147
1147 ### 1148 ###
1149 # Reading data: Featured hashtags
1150 ###
1151 @api_version("3.0.0", "3.0.0", __DICT_VERSION_FEATURED_TAG)
1152 def featured_tags(self):
1153 """
1154 Return the hashtags the logged-in user has set to be featured on
1155 their profile as a list of `featured tag dicts`_.
1156
1157 Returns a list of `featured tag dicts`_.
1158 """
1159 return self.__api_request('GET', '/api/v1/featured_tags')
1160
1161 @api_version("3.0.0", "3.0.0", __DICT_VERSION_HASHTAG)
1162 def featured_tag_suggestions(self):
1163 """
1164 Returns the logged-in users 10 most commonly hashtags.
1165
1166 Returns a list of `hashtag dicts`_.
1167 """
1168 return self.__api_request('GET', '/api/v1/featured_tags/suggestions')
1169
1170 ###
1148 # Reading data: Keyword filters 1171 # Reading data: Keyword filters
1149 ### 1172 ###
1150 @api_version("2.4.3", "2.4.3", __DICT_VERSION_FILTER) 1173 @api_version("2.4.3", "2.4.3", __DICT_VERSION_FILTER)
@@ -2138,6 +2161,28 @@ class Mastodon:
2138 return self.__api_request('POST', url) 2161 return self.__api_request('POST', url)
2139 2162
2140 ### 2163 ###
2164 # Writing data: Featured hashtags
2165 ###
2166 @api_version("3.0.0", "3.0.0", __DICT_VERSION_FEATURED_TAG)
2167 def featured_tag_create(self, name):
2168 """
2169 Creates a new featured hashtag displayed on the logged-in users profile.
2170
2171 Returns a `featured tag dict`_ with the newly featured tag.
2172 """
2173 params = self.__generate_params(locals())
2174 return self.__api_request('POST', '/api/v1/featured_tags', params)
2175
2176 @api_version("3.0.0", "3.0.0", __DICT_VERSION_FEATURED_TAG)
2177 def featured_tag_delete(self, id):
2178 """
2179 Deletes one of the logged-in users featured hashtags.
2180 """
2181 id = self.__unpack_id(id)
2182 url = '/api/v1/featured_tags/{0}'.format(str(id))
2183 self.__api_request('DELETE', url)
2184
2185 ###
2141 # Writing data: Keyword filters 2186 # Writing data: Keyword filters
2142 ### 2187 ###
2143 @api_version("2.4.3", "2.4.3", __DICT_VERSION_FILTER) 2188 @api_version("2.4.3", "2.4.3", __DICT_VERSION_FILTER)
@@ -2982,7 +3027,7 @@ class Mastodon:
2982 """ 3027 """
2983 Parse dates in certain known json fields, if possible. 3028 Parse dates in certain known json fields, if possible.
2984 """ 3029 """
2985 known_date_fields = ["created_at", "week", "day", "expires_at", "scheduled_at", "updated_at"] 3030 known_date_fields = ["created_at", "week", "day", "expires_at", "scheduled_at", "updated_at", "last_status_at"]
2986 for k, v in json_object.items(): 3031 for k, v in json_object.items():
2987 if k in known_date_fields: 3032 if k in known_date_fields:
2988 if v != None: 3033 if v != None:
Powered by cgit v1.2.3 (git 2.41.0)