aboutsummaryrefslogtreecommitdiffstats
path: root/github3/models/user.py
blob: 7ec799989a17d921adfa165bcd02612c565ae157 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# author: David Medina

from .base import BaseResource

class Plan(BaseResource):
    """Github Plan object model."""

    @classmethod
    def idl(self):
        return {
            'strs': ['name'],
            'ints': ['space', 'collaborators', 'private_repos'],
        }

    def __repr__(self):
        return '<Plan %s>' % self.name

class Key(BaseResource):
    """Github Key object model."""

    @classmethod
    def idl(self):
        return {
            'strs': ['url', 'title', 'key'],
            'ints': ['id'],
        }

    def __repr__(self):
        return '<Key %s>' % self.title

class User(BaseResource):
    """Github User object model."""

    @classmethod
    def idl(self):
        return {
            'strs': ['login','avatar_url', 'url', 'name', 'company', 'blog',
                     'location', 'email', 'bio', 'html_url', 'type'],
            'ints': [
                'id', 'public_repos', 'public_gists', 'followers', 'following',
                'total_private_repos', 'owned_private_repos', 'private_gists',
                'disk_usage', 'collaborators'],
            'maps': {'plan': Plan},
            'dates': ['created_at',],
            'bools': ['hireable', ],
        }

    def __repr__(self):
        return '<User %s>' % self.login

    #def handler(self):
    #    return self._gh.user_handler(self.login, force=True)

class AuthUser(User):
    """Github Authenticated User object model."""

    #def handler(self):
    #    return self._gh.user_handler(self.login, force=True, private=True)

    def __repr__(self):
        return '<AuthUser %s>' % self.login