/ github / NotificationSubject.py
NotificationSubject.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2013 AKFish <akfish@gmail.com>                                     #
 4  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
 5  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 6  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
 7  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 8  # Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
 9  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
10  #                                                                              #
11  # This file is part of PyGithub.                                               #
12  # http://pygithub.readthedocs.io/                                              #
13  #                                                                              #
14  # PyGithub is free software: you can redistribute it and/or modify it under    #
15  # the terms of the GNU Lesser General Public License as published by the Free  #
16  # Software Foundation, either version 3 of the License, or (at your option)    #
17  # any later version.                                                           #
18  #                                                                              #
19  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
20  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
21  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
22  # details.                                                                     #
23  #                                                                              #
24  # You should have received a copy of the GNU Lesser General Public License     #
25  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
26  #                                                                              #
27  ################################################################################
28  
29  
30  from typing import Any, Dict
31  
32  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
33  
34  
35  class NotificationSubject(NonCompletableGithubObject):
36      """
37      This class represents Subjects of Notifications. The reference can be found here https://docs.github.com/en/rest/reference/activity#list-notifications-for-the-authenticated-user
38      """
39  
40      def _initAttributes(self) -> None:
41          self._title: Attribute[str] = NotSet
42          self._url: Attribute[str] = NotSet
43          self._latest_comment_url: Attribute[str] = NotSet
44          self._type: Attribute[str] = NotSet
45  
46      def __repr__(self) -> str:
47          return self.get__repr__({"title": self._title.value})
48  
49      @property
50      def title(self) -> str:
51          return self._title.value
52  
53      @property
54      def url(self) -> str:
55          return self._url.value
56  
57      @property
58      def latest_comment_url(self) -> str:
59          return self._latest_comment_url.value
60  
61      @property
62      def type(self) -> str:
63          return self._type.value
64  
65      def _useAttributes(self, attributes: Dict[str, Any]) -> None:
66          if "title" in attributes:  # pragma no branch
67              self._title = self._makeStringAttribute(attributes["title"])
68          if "url" in attributes:  # pragma no branch
69              self._url = self._makeStringAttribute(attributes["url"])
70          if "latest_comment_url" in attributes:  # pragma no branch
71              self._latest_comment_url = self._makeStringAttribute(attributes["latest_comment_url"])
72          if "type" in attributes:  # pragma no branch
73              self._type = self._makeStringAttribute(attributes["type"])