SDK: Add notes (only prometheus)
This commit is contained in:
parent
402f2a0eee
commit
bb83897f0b
4 changed files with 36 additions and 1 deletions
|
@ -15,6 +15,7 @@ from sdk.src.apis.hebe.constants import (
|
||||||
ENDPOINT_EXAM_BYPUPIL,
|
ENDPOINT_EXAM_BYPUPIL,
|
||||||
ENDPOINT_GRADE_BYPUPIL,
|
ENDPOINT_GRADE_BYPUPIL,
|
||||||
ENDPOINT_HEARTBEAT,
|
ENDPOINT_HEARTBEAT,
|
||||||
|
ENDPOINT_NOTE_BYPUPIL,
|
||||||
ENDPOINT_REGISTER_HEBE,
|
ENDPOINT_REGISTER_HEBE,
|
||||||
ENDPOINT_REGISTER_JWT,
|
ENDPOINT_REGISTER_JWT,
|
||||||
ENDPOINT_REGISTER_TOKEN,
|
ENDPOINT_REGISTER_TOKEN,
|
||||||
|
@ -37,6 +38,7 @@ from sdk.src.apis.hebe.student import HebeStudent
|
||||||
from sdk.src.apis.hebe.signer import get_signature_values
|
from sdk.src.apis.hebe.signer import get_signature_values
|
||||||
from sdk.src.models.exam import Exam
|
from sdk.src.models.exam import Exam
|
||||||
from sdk.src.models.grade import Grade
|
from sdk.src.models.grade import Grade
|
||||||
|
from sdk.src.models.note import Note
|
||||||
|
|
||||||
|
|
||||||
class HebeClient:
|
class HebeClient:
|
||||||
|
@ -199,3 +201,9 @@ class HebeClient:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return list(map(Exam.from_hebe_dict, envelope))
|
return list(map(Exam.from_hebe_dict, envelope))
|
||||||
|
|
||||||
|
def get_notes(self, student_id: int):
|
||||||
|
envelope = self._send_request(
|
||||||
|
"GET", ENDPOINT_NOTE_BYPUPIL, params={"pupilId": student_id}
|
||||||
|
)
|
||||||
|
return list(map(Note.from_hebe_dict, envelope))
|
||||||
|
|
|
@ -19,3 +19,4 @@ ENDPOINT_SCHOOL_LUCKY = "mobile/school/lucky"
|
||||||
ENDPOINT_GRADE_BYPUPIL = "mobile/grade/byPupil"
|
ENDPOINT_GRADE_BYPUPIL = "mobile/grade/byPupil"
|
||||||
ENDPOINT_SCHEDULE_WITHCHANGES_BYPUPIL = "mobile/schedule/withchanges/byPupil"
|
ENDPOINT_SCHEDULE_WITHCHANGES_BYPUPIL = "mobile/schedule/withchanges/byPupil"
|
||||||
ENDPOINT_EXAM_BYPUPIL = "mobile/exam/byPupil"
|
ENDPOINT_EXAM_BYPUPIL = "mobile/exam/byPupil"
|
||||||
|
ENDPOINT_NOTE_BYPUPIL = "mobile/note/byPupil"
|
||||||
|
|
|
@ -147,7 +147,7 @@ class PrometheusInterface(CoreInterface):
|
||||||
self._hebe_client.set_rest_url(get_hebe_url(symbol))
|
self._hebe_client.set_rest_url(get_hebe_url(symbol))
|
||||||
self._hebe_client.register_jwt(symbols[symbol])
|
self._hebe_client.register_jwt(symbols[symbol])
|
||||||
|
|
||||||
self._auth_context.symbols = symbols.keys()
|
self._auth_context.symbols = list(symbols.keys())
|
||||||
|
|
||||||
def _login_efeb(self):
|
def _login_efeb(self):
|
||||||
if not self._auth_context.efeb_web_cookies:
|
if not self._auth_context.efeb_web_cookies:
|
||||||
|
@ -254,3 +254,8 @@ class PrometheusInterface(CoreInterface):
|
||||||
self._check_is_auth_context_full()
|
self._check_is_auth_context_full()
|
||||||
self._check_is_student_selected()
|
self._check_is_student_selected()
|
||||||
return self._hebe_client.get_exams(self._student_context.student_id, from_, to)
|
return self._hebe_client.get_exams(self._student_context.student_id, from_, to)
|
||||||
|
|
||||||
|
def get_notes(self):
|
||||||
|
self._check_is_auth_context_full()
|
||||||
|
self._check_is_student_selected()
|
||||||
|
return self._hebe_client.get_notes(self._student_context.student_id)
|
||||||
|
|
21
sdk/src/models/note.py
Normal file
21
sdk/src/models/note.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Note:
|
||||||
|
name: str | None
|
||||||
|
content: str
|
||||||
|
points: str | None
|
||||||
|
creator: str
|
||||||
|
created_at: datetime
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_hebe_dict(data: dict):
|
||||||
|
return Note(
|
||||||
|
name=data["Category"]["Name"] if data["Category"] else None,
|
||||||
|
content=data["Content"],
|
||||||
|
points=str(data["Points"]) if data["Points"] else None,
|
||||||
|
creator=data["Creator"]["DisplayName"],
|
||||||
|
created_at=datetime.fromtimestamp(data["DateValid"]["Timestamp"] / 1000),
|
||||||
|
)
|
Loading…
Add table
Reference in a new issue