Skip to content

Commit

Permalink
feat: add seating info handler to main package
Browse files Browse the repository at this point in the history
  • Loading branch information
silicoflare committed Apr 24, 2024
1 parent 2c3c337 commit 204f130
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pesuacademy/pesuacademy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from bs4 import BeautifulSoup

from pesuacademy import util
from pesuacademy.models.seating_info import SeatingInfo
from pesuacademy.util.page import PageHandler
from .exceptions import CSRFTokenError, AuthenticationError
from .models import Profile, ClassAndSectionInfo, Course
Expand Down Expand Up @@ -155,3 +156,14 @@ def attendance(self, semester: Optional[int] = None) -> dict[int, list[Course]]:
raise AuthenticationError("You need to authenticate first.")
attendance_info = self.page_handler.get_attendance(semester)
return attendance_info

def seating_info(self) -> list[SeatingInfo]:
"""
Get the seating information of the currently authenticated user.
:return: The seating information.
"""
if not self._authenticated:
raise AuthenticationError("You need to authenticate first.")
seating_info = self.page_handler.get_seating_info()
return seating_info
3 changes: 3 additions & 0 deletions pesuacademy/util/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ def get_courses(self, semester: Optional[int] = None):
def get_attendance(self, semester: Optional[int] = None):
semester_ids = self.get_semester_ids_from_semester_number(semester)
return self.attendance_page_handler.get_page(self.__session, semester_ids)

def get_seating_info(self):
return pages.SeatingInfoHandler.get_page(self.__session)

0 comments on commit 204f130

Please sign in to comment.