aboutsummaryrefslogtreecommitdiffstats
path: root/github3/models/user.py
blob: aed6f09bb1274beb04328293754a56344183b379 (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
66
67
68
69
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

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', 'gravatar_id', '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>' % getattr(self, 'login', 'without user')

    #def handler(self):
    #    return self._gh.users


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

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

    #def handler(self):
    #    return self._gh.users