From 914e22cc55dc215bb45899622b15f00e53ded1f4 Mon Sep 17 00:00:00 2001 From: Alvaro Molina Alvarez Date: Tue, 24 Jan 2017 18:16:20 +0100 Subject: [PATCH] adding update_avatar client method --- pydiscourse/client.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pydiscourse/client.py b/pydiscourse/client.py index 09b6296..e9c7c17 100644 --- a/pydiscourse/client.py +++ b/pydiscourse/client.py @@ -233,6 +233,23 @@ class DiscourseClient(object): url = '/users/{0}/preferences/avatar/pick'.format(username) return self._put(url, **kwargs) + def update_avatar(self, username, url, **kwargs): + """ + + Args: + username: + url: + **kwargs: + + Returns: + + """ + kwargs['type'] = 'avatar' + kwargs['synchronous'] = 'true' + upload_response = self._post('/uploads', url=url, **kwargs) + return self._put('/users/{0}/preferences/avatar/pick'.format(username), + upload_id=upload_response['id'], **kwargs) + def update_email(self, username, email, **kwargs): """