diff options
Diffstat (limited to 'pygithub3/services/users/__init__.py')
-rw-r--r-- | pygithub3/services/users/__init__.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/pygithub3/services/users/__init__.py b/pygithub3/services/users/__init__.py new file mode 100644 index 0000000..29a8e1c --- /dev/null +++ b/pygithub3/services/users/__init__.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from ..base import Service +from .keys import Keys +from .emails import Emails +from .followers import Followers + + +class User(Service): + """ Consume `Users API <http://developer.github.com/v3/users>`_ """ + + def __init__(self, **config): + self.keys = Keys(**config) + self.emails = Emails(**config) + self.followers = Followers(**config) + super(User, self).__init__(**config) + + def get(self, user=None): + """ Get a single user + + :param str user: Username + + If you call it without user and you are authenticated, get the + authenticated user. + + .. warning:: + If you aren't authenticated and call without user, it returns 403 + + :: + + user_service.get('copitux') + user_service.get() + """ + request = self.make_request('users.get', user=user) + return self._get(request) + + def update(self, data): + """ Update the authenticated user + + :param dict data: Input to update + + :: + + user_service.update(dict(name='new_name', bio='new_bio')) + """ + request = self.make_request('users.update', body=data) + return self._patch(request) |