diff --git a/src/auth/endpoints.rs b/src/auth/endpoints.rs new file mode 100644 index 0000000..e7b9a5d --- /dev/null +++ b/src/auth/endpoints.rs @@ -0,0 +1,22 @@ +use std::marker::PhantomData; + +use crate::{ContentType, Endpoint, LoginSuccess, OpenIdDiscovery, auth::login::LoginRequest}; + +pub const LOGIN_ENDPOINT: Endpoint = Endpoint::Post { + url: "/api/login", + auth: false, + content_type: ContentType::Urlencoded, + _types: PhantomData, +}; + +pub const OPEN_ID_DISCOVERY_ENDPOINT: Endpoint = Endpoint::Get { + url: "/.well-known/openid-configuration", + auth: false, + _types: PhantomData, +}; + +pub const LOGIN_TOKEN_ENDPOINT: Endpoint = Endpoint::Get { + url: "/api/3/logintoken", + auth: true, + _types: PhantomData, +}; diff --git a/src/auth/login.rs b/src/auth/login.rs index c7716c8..90d9b8e 100644 --- a/src/auth/login.rs +++ b/src/auth/login.rs @@ -15,6 +15,15 @@ pub struct LoginSuccess { pub app_version: String, } +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub struct LoginRequest { + client_id: String, + grant_type: String, + username: String, + password: String, +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum TokenType { diff --git a/src/auth/mod.rs b/src/auth/mod.rs index 6da0d2a..c897508 100644 --- a/src/auth/mod.rs +++ b/src/auth/mod.rs @@ -1,7 +1,9 @@ +mod endpoints; mod login; mod open_id_discovery; mod user_jwt_claim; -pub use login::{LoginSuccess, TokenType}; -pub use open_id_discovery::OpenIdDiscovery; -pub use user_jwt_claim::UserJwtClaim; +pub use endpoints::*; +pub use login::*; +pub use open_id_discovery::*; +pub use user_jwt_claim::*; diff --git a/src/endpoints.rs b/src/endpoints.rs new file mode 100644 index 0000000..b26ae89 --- /dev/null +++ b/src/endpoints.rs @@ -0,0 +1,20 @@ +use std::marker::PhantomData; + +pub enum Endpoint { + Get { + url: &'static str, + auth: bool, + _types: PhantomData (Response, Request)>, + }, + Post { + url: &'static str, + auth: bool, + content_type: ContentType, + _types: PhantomData (Response, Request)>, + }, +} + +pub enum ContentType { + Urlencoded, + Json, +} diff --git a/src/events.rs b/src/events.rs index 9c35ef5..cd4fb40 100644 --- a/src/events.rs +++ b/src/events.rs @@ -2,6 +2,8 @@ use crate::{Room, RoomSet, SchoolClass, SchoolClassSet, StdType, Student, Teache use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; +/// /api/3/events GET body response +/// Get /api/3/events/my GET body response #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Events { diff --git a/src/homeworks/endpoints.rs b/src/homeworks/endpoints.rs new file mode 100644 index 0000000..8df1c77 --- /dev/null +++ b/src/homeworks/endpoints.rs @@ -0,0 +1,25 @@ +use std::marker::PhantomData; + +use crate::{Endpoint, HomeworkList}; + +pub const HOMEWORKS_COUNT_ENDPOINT: Endpoint<(), i64> = Endpoint::Get { + url: "/api/3/homeworks/count-actual", + auth: true, + _types: PhantomData, +}; + +/// ID = homework ID (String) +/// finished = homework state (bool) +pub const HOMEWORK_DONE_ENDPOINT: Endpoint<(), bool> = Endpoint::Get { + url: "api/3/homeworks/:id/student-done/:finished", + auth: true, + _types: PhantomData, +}; + + +/// Query from and to (Datetime) +pub const HOMEWORKS_ENDPOINT: Endpoint<(), HomeworkList> = Endpoint::Get { + url: "api/3/homeworks", + auth: true, + _types: PhantomData, +}; \ No newline at end of file diff --git a/src/homework.rs b/src/homeworks/homework.rs similarity index 100% rename from src/homework.rs rename to src/homeworks/homework.rs diff --git a/src/homeworks/mod.rs b/src/homeworks/mod.rs new file mode 100644 index 0000000..e10cf70 --- /dev/null +++ b/src/homeworks/mod.rs @@ -0,0 +1,5 @@ +mod endpoints; +mod homework; + +pub use endpoints::*; +pub use homework::*; diff --git a/src/lib.rs b/src/lib.rs index dbaec2d..7ed1a5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,11 +4,12 @@ mod attachment; //campaign mod auth; mod campaign; +mod endpoints; mod error; mod events; mod gdpr; //komens -mod homework; //TDOS +mod homeworks; //TDOS //marking mod marks; mod payments; @@ -27,14 +28,15 @@ pub use api_info::ApiInfo; pub use attachment::AttachmentInfo; pub use auth::*; pub use campaign::Campaign; +pub use endpoints::*; pub use error::{Error, ModelState, StringArray}; pub use events::{Event, EventTime, EventType, Events}; pub use gdpr::{ GdprCommissioner, GdprCommissioners, GdprConsent, GdprConsentRights, GdprConsentState, GdprValidity, }; -pub use homework::{HomeworkList, HomeworkListItem}; -pub use marks::{Mark, MarkConfirmationStatus, Marks, SubjectMarks}; +pub use homeworks::*; +pub use marks::*; pub use payments::*; pub use semester::{ CertificateTerm, CertificateTerms, FinalMark, PedagogicalMeasure, PedagogicalMeasures, @@ -43,7 +45,7 @@ pub use stdtype::{ Room, RoomSet, SchoolClass, SchoolClassSet, StdClassGroup, StdType, StdTypeNullable, Student, Teacher, TeacherSet, TimetableStudent, }; -pub use subjects::{Subject, Subjects}; +pub use subjects::*; pub use substitutions::{ ChangeDisplayType, ChangeLessonInfo, SubstitutionChange, SubstitutionChangeType, Substitutions, }; diff --git a/src/marks/endpoints.rs b/src/marks/endpoints.rs new file mode 100644 index 0000000..5c6a55c --- /dev/null +++ b/src/marks/endpoints.rs @@ -0,0 +1,22 @@ +use std::marker::PhantomData; + +use crate::{ContentType, Endpoint, Marks}; + +pub const CONFIRM_MARKS_ENDPOINT: Endpoint<(), Vec> = Endpoint::Post { + url: "/api/3/marks/SetClassificationConfirmation", + auth: true, + content_type: ContentType::Json, + _types: PhantomData, +}; + +pub const COUNT_NEW_MARKS_ENDPOINT: Endpoint = Endpoint::Get { + url: "/api/3/marks/count-new", + auth: true, + _types: PhantomData, +}; + +pub const MARKS_ENDPOINT: Endpoint = Endpoint::Get { + url: "/api/3/marks", + auth: true, + _types: PhantomData, +}; diff --git a/src/marks/mod.rs b/src/marks/mod.rs new file mode 100644 index 0000000..1530cc9 --- /dev/null +++ b/src/marks/mod.rs @@ -0,0 +1,5 @@ +mod endpoints; +mod subject_marks; + +pub use endpoints::*; +pub use subject_marks::*; diff --git a/src/marks.rs b/src/marks/subject_marks.rs similarity index 97% rename from src/marks.rs rename to src/marks/subject_marks.rs index 3c02a26..ddac43f 100644 --- a/src/marks.rs +++ b/src/marks/subject_marks.rs @@ -27,7 +27,7 @@ pub struct SubjectMarks { pub struct Mark { pub mark_date: DateTime, pub edit_date: DateTime, - pub is_invalid_date: Option, + pub is_invalid_date: bool, pub teacher_id: Option, pub subject_id: String, pub is_new: bool, diff --git a/src/subjects/endpoints.rs b/src/subjects/endpoints.rs new file mode 100644 index 0000000..8ee5e49 --- /dev/null +++ b/src/subjects/endpoints.rs @@ -0,0 +1,9 @@ +use std::marker::PhantomData; + +use crate::{Endpoint, Subjects}; + +pub const SUBJECTS_ENDPOINT: Endpoint<(), Subjects> = Endpoint::Get { + url: "/api/3/subjects", + auth: true, + _types: PhantomData, +}; diff --git a/src/subjects/mod.rs b/src/subjects/mod.rs new file mode 100644 index 0000000..1056ce2 --- /dev/null +++ b/src/subjects/mod.rs @@ -0,0 +1,5 @@ +mod endpoints; +mod subject_types; + +pub use endpoints::*; +pub use subject_types::*; diff --git a/src/subjects.rs b/src/subjects/subject_types.rs similarity index 100% rename from src/subjects.rs rename to src/subjects/subject_types.rs diff --git a/src/user/endpoints.rs b/src/user/endpoints.rs new file mode 100644 index 0000000..9d4f301 --- /dev/null +++ b/src/user/endpoints.rs @@ -0,0 +1,15 @@ +use std::marker::PhantomData; + +use crate::{Endpoint, UserInfo}; + +pub const USER_INFO_ENDPOINT: Endpoint = Endpoint::Get { + url: "/api/3/user", + auth: true, + _types: PhantomData, +}; + +pub const STUDENT_AT_SCHOOL_ENDPOINT: Endpoint = Endpoint::Get { + url: "/api/3/user/student-at-school", + auth: true, + _types: PhantomData, +}; diff --git a/src/user/mod.rs b/src/user/mod.rs index fd87e59..ae4154d 100644 --- a/src/user/mod.rs +++ b/src/user/mod.rs @@ -1,7 +1,9 @@ +mod endpoints; mod modules; mod setting_modules; mod user_info; +pub use endpoints::*; pub use modules::*; pub use setting_modules::*; pub use user_info::*; diff --git a/tracker.md b/tracker.md index 1c2135a..34248c2 100644 --- a/tracker.md +++ b/tracker.md @@ -24,4 +24,104 @@ - [ ] OpenApi schema generation - [ ] documentation - [ ] tests -- [ ] constructors \ No newline at end of file +- [ ] constructors + +# Endpoints +- [ ] /api/3/komens/message/:messageId/mark-as-read +- [x] /api/3/marks +- [x] /api/3/homeworks/:id/student-done/:finished +- [ ] /api/3/marking/atoms/:atomId/headers +- [ ] /api/3/payments/classfund/teacher/students/:classId +- [ ] /api/3/classbook/lessonTags +- [ ] /api/3/komens/messages/rating/:messageId +- [ ] /api/3/absence/student +- [ ] /api/3/webmodule +- [ ] /api/3/timetable/actual +- [ ] /api/3/payments/classfund/teacher/document/detail/:documentId +- [ ] /api/3 +- [ ] /api/3/komens/attachment/:id +- [ ] /api/3/subjects/themes/:subjectId +- [ ] /api/3/payments/classfund +- [ ] /api/3/gdpr/consents/person/child +- [ ] /api/3/komens/concept/:conceptId +- [ ] /api/3/marks/measures +- [ ] /api/3/unregister-user-notification +- [ ] /api/3/gdpr/consent/:id/agree +- [x] /api/3/marks/count-new +- [ ] /api/3/komens/concept +- [ ] /api/3/timetable/permanent +- [ ] /api/3/komens/messages/noticeboard +- [ ] /api/3/komens/messages/apology/:messageId +- [ ] /api/3/komens/messages/received/:messageId +- [x] /api/3/user +- [ ] /api/3/payments/regularpayments/detail/:paymentId +- [ ] /api/3/substitutions +- [ ] /api/3/marks/what-if +- [ ] /api/3/gdpr/commissioner/send-objection +- [ ] /api/3/gdpr/consents/person/new +- [ ] /api/3/lesson/:lessonId/absence +- [ ] /api/3/payments/regularpayments/summary +- [ ] /api/3/emergency/startemergency +- [ ] /api/3/timetable/permanent/class/:classId +- [ ] /api/3/gdpr/commissioner/send-report +- [ ] /api/3/komens/message/:messageId/mark-as-unhidden +- [ ] /api/3/lesson/:lessonId/studentsTimetable +- [ ] /api/3/marks/final +- [ ] /api/3/timetable/student/:studentId +- [ ] /api/3/marking/atom/:atomId/headerOptions +- [ ] /api/3/gdpr/consent/:id/disagree +- [ ] /api/3/komens/messages/sent +- [ ] /api/3/emergency/configuration +- [ ] /api/3/komens/message +- [ ] /api/3/komens/message/:messageId/mark-as-hidden +- [ ] /api/3/lesson/:lessonId/past +- [ ] /api/3/komens/attachment +- [ ] /api/3/komens/messages/received +- [ ] /api/3/login/:token +- [ ] /api/3/komens/concepts +- [ ] /api/3/komens/messages/received/unread +- [ ] /api/3/payments/regularpayments/teacher/prescriptions/:prescriptionId +- [ ] /api/3/timetable/actual/class/:classId +- [ ] /api/3/gdpr/consents/person +- [ ] /api/3/komens/messages/unread +- [ ] /api/3/absence +- [ ] /api/3/komens/message/:messageId/mark-as-confirmed +- [ ] /api/3/komens/messages/apology +- [ ] /api/3/events +- [ ] /api/3/komens/concepts/count +- [ ] /api/3/payments/regularpayments/teacher/prescriptions/:prescriptionId/students +- [ ] /api/3/payments/regularpayments +- [ ] /api/3/komens/messages/noticeboard/:messageId& +- [ ] /api/3/komens/message-types/reply/:messageId +- [ ] /api/3/payments/regularpayments/teacher/prescriptions +- [x] /api/3/marks/SetClassificationConfirmation +- [x] /api/3/homeworks/count-actual +- [ ] /api/3/gdpr/consent/:id/revoke-request +- [ ] /api/3/payments/regularpayments/teacher/prescriptions/:prescriptionId/students/:studentId +- [ ] /api/3/marking/atoms +- [ ] /api/3/absence/canexcuse/:studentId +- [ ] /api/3/komens/rating-templates +- [ ] /api/3/emergency/participantsselection +- [ ] /api/3/komens/messages/noticeboard/unread +- [ ] /api/3/komens/message-types +- [ ] /api/3/events/my +- [ ] /api/3/gdpr/commissioners +- [ ] /api/3/classbook/:recordId +- [ ] /api/3/marking/marks/:atomId +- [ ] /api/3/substitutions/cycles +- [x] /api/3/logintoken +- [ ] /api/3/komens/message-types/edit/:messageId +- [ ] /api/3/payments/classfund/teacher/documents/:classId +- [ ] /api/3/payments/classfund/summary +- [ ] /api/3/register-notification +- [ ] /api/3/payments/classfund/paymentsinfo +- [ ] /api/3/komens/messages/rating +- [ ] /api/3/komens/message/:messageId +- [x] /api/3/homeworks +- [x] /api/3/subjects +- [ ] /api/3/classbook +- [x] /api/3/user/student-at-school +- [ ] /api/3/payments/classfund/teacher/summary +- [ ] /api/3/komens/messages/sent/:messageId +- [x] /api/login +- [x] /.well-known/openid-configuration \ No newline at end of file