Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications (recreated) #288

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pronotepy/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,23 @@ def generate_timetable_pdf(
+ response["donneesSec"]["donnees"]["url"]["V"]
)

def notifications(self) -> List[dataClasses.Notifications]:
"""the notification"""

response = self.post("CentraleNotifications", 7)
n_list = response["donneesSec"]["donnees"]["liste"]["V"]
out = []
for n_test in n_list:
no = dataClasses.Notifications(n_test)
out.append(no)
return out

@property
def notification_number(self) -> int:
response = self.post("CentraleNotifications", 7)
notif_number = response["donneesSec"]["donnees"].get("nbNotifs")
return notif_number

def get_recipients(self) -> List[dataClasses.Recipient]:
"""Get recipients for new discussion

Expand Down
42 changes: 42 additions & 0 deletions pronotepy/dataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"Delay",
"TeachingStaff",
"Report",
"Notifications"
)

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -2166,3 +2167,44 @@ def __init__(self, json_dict: dict) -> None:
)

del self._resolver



class Notifications(Object):

"""
Represents the notifications. You shouldn't have to create this class manually.

Attributes:
part (str): part of the notification
ident (str): ident of the notification
"""

def __init__(self, json_dict: dict) -> None:
super().__init__(json_dict)

self.part: str = self._resolver(str, "L")
self.ident: str = self._resolver(str, "ident")

self.notifications: List[Notifications.Notification] = self._resolver(
lambda x: [Notifications.Notification(i) for i in x], "liste", "V"
)
del self._resolver

class Notification(Object):
"""
Represents the notification. You shouldn't have to create this class manually.

Attributes:
id (str): id of the notification
message (str): message of the notification
type (int): type of the notification
action (int): action of the notification
"""
def __init__(self, json_dict: dict) -> None:
super().__init__(json_dict)

self.id: str = self._resolver(str, "id")
self.message: str = self._resolver(str, "message", "V")
self.type: int = self._resolver(int, "type")
self.action: int = self._resolver(int, "action")
Loading