diff options
Diffstat (limited to 'github3/models.py')
-rw-r--r-- | github3/models.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/github3/models.py b/github3/models.py index 7b11031..d17d51b 100644 --- a/github3/models.py +++ b/github3/models.py @@ -16,6 +16,7 @@ class BaseResource(object): _dates = [] _bools = [] _map = {} + _writeable = [] def __init__(self): @@ -53,21 +54,48 @@ class BaseResource(object): _gh = gh ) + def update(self): + pass + + def setattr(self, k, v): + # TODO: when writable key changed, + pass class User(BaseResource): """Github User object model.""" - _strings = ['login', 'gravatar_url', 'url', 'name', 'company', - 'blog', 'location', 'email', 'bio', 'html_url'] + _strings = [ + 'login','gravatar_url', 'url', 'name', 'company', 'blog', 'location', + 'email', 'bio', 'html_url'] _ints = ['id', 'public_repos', 'public_gists', 'followers', 'following'] _datetimes = ['created_at',] _booleans = ['hireable', ] _map = {} + _writeable = ['name', 'email', 'blog', 'company', 'location', 'hireable', 'bio'] def __init__(self): super(User, self).__init__() def __repr__(self): - return '<user {0}>'.format(self.login)
\ No newline at end of file + return '<user {0}>'.format(self.login) + + + def _update(self): + """Update the authenticated user.""" + + # TODO: check that user is authenticated + + args = to_api( + dict( + favorite=self.favorite, + archive=self.archive, + read_percent=self.read_percent, + ), + int_keys=('favorite', 'archive') + ) + + r = self._rdd._post_resource(('bookmarks', self.id), **args) + + return r
\ No newline at end of file |