1# -*- coding: utf-8 -*-
2
3############################ Copyrights and license ############################
4#                                                                              #
5# Copyright 2017 Jannis Gebauer <ja.geb@me.com>                                #
6# Copyright 2017 Simon <spam@esemi.ru>                                         #
7# Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
8#                                                                              #
9# This file is part of PyGithub.                                               #
10# http://pygithub.readthedocs.io/                                              #
11#                                                                              #
12# PyGithub is free software: you can redistribute it and/or modify it under    #
13# the terms of the GNU Lesser General Public License as published by the Free  #
14# Software Foundation, either version 3 of the License, or (at your option)    #
15# any later version.                                                           #
16#                                                                              #
17# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
18# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
19# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
20# details.                                                                     #
21#                                                                              #
22# You should have received a copy of the GNU Lesser General Public License     #
23# along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
24#                                                                              #
25################################################################################
26
27import github.GithubObject
28
29
30class Invitation(github.GithubObject.CompletableGithubObject):
31    """
32    This class represents repository invitations. The reference can be found here https://developer.github.com/v3/repos/invitations/
33    """
34
35    def __repr__(self):
36        return self.get__repr__({"id": self._id.value})
37
38    @property
39    def id(self):
40        """
41        :type: integer
42        """
43        self._completeIfNotSet(self._id)
44        return self._id.value
45
46    @property
47    def permissions(self):
48        """
49        :type: string
50        """
51        self._completeIfNotSet(self._permissions)
52        return self._permissions.value
53
54    @property
55    def created_at(self):
56        """
57        :type: string
58        """
59        self._completeIfNotSet(self._created_at)
60        return self._created_at.value
61
62    @property
63    def invitee(self):
64        """
65        :type: NamedUser
66        """
67        self._completeIfNotSet(self._invitee)
68        return self._invitee.value
69
70    @property
71    def inviter(self):
72        """
73        :type: NamedUser
74        """
75        self._completeIfNotSet(self._inviter)
76        return self._inviter.value
77
78    @property
79    def url(self):
80        """
81        :type: string
82        """
83        self._completeIfNotSet(self._url)
84        return self._url.value
85
86    @property
87    def html_url(self):
88        """
89        :type: string
90        """
91        self._completeIfNotSet(self._html_url)
92        return self._html_url.value
93
94    @property
95    def repository(self):
96        """
97        :type: Repository
98        """
99        self._completeIfNotSet(self._repository)
100        return self._repository.value
101
102    def _initAttributes(self):
103        self._id = github.GithubObject.NotSet
104        self._permissions = github.GithubObject.NotSet
105        self._created_at = github.GithubObject.NotSet
106        self._invitee = github.GithubObject.NotSet
107        self._inviter = github.GithubObject.NotSet
108        self._url = github.GithubObject.NotSet
109        self._html_url = github.GithubObject.NotSet
110        self._repository = github.GithubObject.NotSet
111
112    def _useAttributes(self, attributes):
113        if "repository" in attributes:  # pragma no branch
114            self._repository = self._makeClassAttribute(
115                github.Repository.Repository, attributes["repository"]
116            )
117        if "created_at" in attributes:  # pragma no branch
118            self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
119        if "invitee" in attributes:  # pragma no branch
120            self._invitee = self._makeClassAttribute(
121                github.NamedUser.NamedUser, attributes["invitee"]
122            )
123        if "inviter" in attributes:  # pragma no branch
124            self._inviter = self._makeClassAttribute(
125                github.NamedUser.NamedUser, attributes["inviter"]
126            )
127        if "id" in attributes:  # pragma no branch
128            self._id = self._makeIntAttribute(attributes["id"])
129
130        if "permissions" in attributes:  # pragma no branch
131            self._permissions = self._makeStringAttribute(attributes["permissions"])
132        if "url" in attributes:  # pragma no branch
133            self._url = self._makeStringAttribute(attributes["url"])
134        if "html_url" in attributes:  # pragma no branch
135            self._html_url = self._makeStringAttribute(attributes["html_url"])
136