From 35536247dbcc9572ac555d3ab04f780f0725c35e Mon Sep 17 00:00:00 2001 From: vextrixes <113197359+vextrixes@users.noreply.github.com> Date: Sun, 1 Nov 2026 01:08:28 +0100 Subject: [PATCH] small refactors --- src/absence/absence.rs | 20 ++----- src/absence/endpoints.rs | 16 +++--- src/auth/endpoints.rs | 3 +- src/endpoints.rs | 1 + src/events/endpoints.rs | 3 +- src/events/event.rs | 32 ++++------- src/events/event_time.rs | 10 ++++ src/events/mod.rs | 2 + src/gdpr/endpoints.rs | 3 +- src/gdpr/gdpr.rs | 78 --------------------------- src/gdpr/gdpr_commissioner.rs | 19 +++++++ src/gdpr/gdpr_consent.rs | 28 ++++++++++ src/gdpr/gdpr_consent_rights.rs | 9 ++++ src/gdpr/gdpr_consent_state.rs | 14 +++++ src/gdpr/gdpr_validity.rs | 11 ++++ src/gdpr/mod.rs | 12 ++++- src/homework/endpoints.rs | 3 +- src/homework/homeworks.rs | 25 +++++---- src/marks/endpoints.rs | 3 +- src/marks/mark.rs | 31 +++++++++++ src/marks/mark_confirmation_status.rs | 10 ++++ src/marks/mod.rs | 4 ++ src/marks/subject_marks.rs | 45 ++-------------- src/others/endpoints.rs | 3 +- src/payments/endpoints.rs | 3 +- src/semester/endpoints.rs | 3 +- src/semester/semester.rs | 3 +- src/stdtype.rs | 18 +------ src/subjects/endpoints.rs | 3 +- src/substitutions/endpoints.rs | 3 +- src/substitutions/substitutions.rs | 3 +- src/teaching/endpoints.rs | 3 +- src/teaching/teaching.rs | 3 +- src/timetable/endpoints.rs | 5 +- src/timetable/mod.rs | 4 +- src/timetable/timetable.rs | 9 ++-- src/user/endpoints.rs | 3 +- src/user/user_info.rs | 9 ++-- 38 files changed, 213 insertions(+), 244 deletions(-) create mode 100644 src/events/event_time.rs delete mode 100644 src/gdpr/gdpr.rs create mode 100644 src/gdpr/gdpr_commissioner.rs create mode 100644 src/gdpr/gdpr_consent.rs create mode 100644 src/gdpr/gdpr_consent_rights.rs create mode 100644 src/gdpr/gdpr_consent_state.rs create mode 100644 src/gdpr/gdpr_validity.rs create mode 100644 src/marks/mark.rs create mode 100644 src/marks/mark_confirmation_status.rs diff --git a/src/absence/absence.rs b/src/absence/absence.rs index 1cafb2e..f5ce811 100644 --- a/src/absence/absence.rs +++ b/src/absence/absence.rs @@ -1,11 +1,10 @@ +use crate::{Hour, StdType, StdTypeNullable}; use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; -use crate::{Hour, StdType, StdTypeNullable}; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] -pub struct StudentAbsenceOverviewResponse { +pub struct AbsenceOverviewResponse { pub percentage_threshold: f64, //TODO: cutom type (u8) pub absences: Vec, pub absences_per_subject: Option>, @@ -36,18 +35,10 @@ pub struct SubjectAbsence { pub distance_teaching: u16, } -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SubjectAbsenceOverviewResponse { - pub percentage_threshold: f64, - pub absences: Option>, - pub absences_per_subject: Option>, -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct StudentTimetableAbsenceResponse { - pub student: Option, + pub student: Option, pub days: Vec, pub absent_type_options: Vec, } @@ -60,7 +51,7 @@ pub struct AbsenceTypeOption { pub absent_kind_required: bool, pub absent_note_enabled: bool, pub next_absent_type: AbsentType, - pub absent_kinds: Vec, + pub absent_kinds: Vec, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -76,9 +67,6 @@ pub enum AbsentType { NoAbsent, } -type StudentInfo = StdTypeNullable; -type AbsenceKind = StdType; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct AbsenceSubject { diff --git a/src/absence/endpoints.rs b/src/absence/endpoints.rs index 354fa78..e18c6ac 100644 --- a/src/absence/endpoints.rs +++ b/src/absence/endpoints.rs @@ -1,9 +1,8 @@ -use std::marker::PhantomData; - use crate::{ - ContentType, Endpoint, ExcuseAbsenceResponse, StudentAbsenceOverviewResponse, + AbsenceOverviewResponse, ContentType, Endpoint, ExcuseAbsenceResponse, StudentTimetableAbsenceResponse, }; +use std::marker::PhantomData; pub const CAN_STUDENT_EXCUSE_ABSENCE_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/absence/canexcuse/{studentId}", @@ -11,12 +10,11 @@ pub const CAN_STUDENT_EXCUSE_ABSENCE_ENDPOINT: Endpoint = Endpoint::Ge _types: PhantomData, }; -pub const GET_STUDENT_ABSENCE_ENDPOINT: Endpoint = - Endpoint::Get { - url: "/api/3/absence/student", - auth: true, - _types: PhantomData, - }; +pub const GET_STUDENT_ABSENCE_ENDPOINT: Endpoint = Endpoint::Get { + url: "/api/3/absence/student", + auth: true, + _types: PhantomData, +}; pub const GET_STUDENT_TIMETABLE_WITH_ABSENCES_ENDPOINT: Endpoint< StudentTimetableAbsenceResponse, diff --git a/src/auth/endpoints.rs b/src/auth/endpoints.rs index e7b9a5d..3a0db5f 100644 --- a/src/auth/endpoints.rs +++ b/src/auth/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{ContentType, Endpoint, LoginSuccess, OpenIdDiscovery, auth::login::LoginRequest}; +use std::marker::PhantomData; pub const LOGIN_ENDPOINT: Endpoint = Endpoint::Post { url: "/api/login", diff --git a/src/endpoints.rs b/src/endpoints.rs index 9c7a8a1..7691458 100644 --- a/src/endpoints.rs +++ b/src/endpoints.rs @@ -1,6 +1,7 @@ use std::marker::PhantomData; pub enum Endpoint { + //TODO: better url handling. (defining api version/is base url used/query/url params) Get { url: &'static str, auth: bool, diff --git a/src/events/endpoints.rs b/src/events/endpoints.rs index bdd3773..df6da5e 100644 --- a/src/events/endpoints.rs +++ b/src/events/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{Endpoint, Events}; +use std::marker::PhantomData; pub const EVENTS_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/events", diff --git a/src/events/event.rs b/src/events/event.rs index 9c35ef5..4eb3dfa 100644 --- a/src/events/event.rs +++ b/src/events/event.rs @@ -1,38 +1,28 @@ -use crate::{Room, RoomSet, SchoolClass, SchoolClassSet, StdType, Student, Teacher, TeacherSet}; +use crate::{EventTime, StdType}; use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct Events { - pub events: Vec, -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Event { pub id: String, pub title: String, pub description: String, - pub event_type: EventType, + pub event_type: StdType, pub times: Vec, - pub classes: Vec, - pub class_sets: Vec, - pub teachers: Vec, - pub teacher_sets: Vec, - pub rooms: Vec, - pub room_sets: Vec, - pub students: Vec, + pub classes: Vec, + pub class_sets: Vec, + pub teachers: Vec, + pub teacher_sets: Vec, + pub rooms: Vec, + pub room_sets: Vec, + pub students: Vec, pub note: Option, pub date_changed: DateTime, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] -pub struct EventTime { - pub whole_day: bool, - pub start_time: Option>, - pub end_time: Option>, +pub struct Events { + pub events: Vec, } - -pub type EventType = StdType; diff --git a/src/events/event_time.rs b/src/events/event_time.rs new file mode 100644 index 0000000..72f2b0b --- /dev/null +++ b/src/events/event_time.rs @@ -0,0 +1,10 @@ +use chrono::{DateTime, FixedOffset}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct EventTime { + pub whole_day: bool, + pub start_time: Option>, + pub end_time: Option>, +} diff --git a/src/events/mod.rs b/src/events/mod.rs index 2dc3044..1581bb1 100644 --- a/src/events/mod.rs +++ b/src/events/mod.rs @@ -1,5 +1,7 @@ mod endpoints; mod event; +mod event_time; pub use endpoints::*; pub use event::*; +pub use event_time::*; diff --git a/src/gdpr/endpoints.rs b/src/gdpr/endpoints.rs index af65a43..6d4bf56 100644 --- a/src/gdpr/endpoints.rs +++ b/src/gdpr/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{ContentType, Endpoint, GdprCommissioners, GdprConsents}; +use std::marker::PhantomData; pub const SEND_GDPR_OBJECTION_ENDPOINT: Endpoint<(), String> = Endpoint::Post { url: "/api/3/gdpr/commissioner/send-objection", diff --git a/src/gdpr/gdpr.rs b/src/gdpr/gdpr.rs deleted file mode 100644 index a2bedaf..0000000 --- a/src/gdpr/gdpr.rs +++ /dev/null @@ -1,78 +0,0 @@ -use chrono::{DateTime, FixedOffset}; -use serde::{Deserialize, Serialize}; - -use crate::UserType; - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct GdprCommissioners { - pub commissioners: Vec, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct GdprCommissioner { - pub id: String, - pub name: String, - pub mobile: String, - pub phone: String, - pub email: String, - pub web: Option, - pub data_box: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct GdprConsent { - pub id: i64, - pub person_type: UserType, - pub person_id: String, - pub created: DateTime, - pub validity: GdprValidity, - pub valid_from: DateTime, - pub state: GdprConsentState, - pub title: Option, - pub personal_data: Option, - pub usage_purpose: Option, - pub valid_to: Option>, - pub valid_years: Option, - pub rights: Option, - pub body: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum GdprValidity { - EndOfStudy, - EndOfStudyPlusYears, - ToAppeal, - Unknown, - Validity, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum GdprConsentState { - Agreed, - Cancelled, - Disagreed, - Expired, - NewConsent, - RevokeRequested, - Revoked, - Unknown, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct GdprConsentRights { - pub can_agree: bool, - pub can_disagree: bool, - pub can_revoke_request: bool, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct GdprConsents { - pub person_consents: Vec, -} diff --git a/src/gdpr/gdpr_commissioner.rs b/src/gdpr/gdpr_commissioner.rs new file mode 100644 index 0000000..af45456 --- /dev/null +++ b/src/gdpr/gdpr_commissioner.rs @@ -0,0 +1,19 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct GdprCommissioner { + pub id: String, + pub name: String, + pub mobile: String, + pub phone: String, + pub email: String, + pub web: Option, + pub data_box: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct GdprCommissioners { + pub commissioners: Vec, +} diff --git a/src/gdpr/gdpr_consent.rs b/src/gdpr/gdpr_consent.rs new file mode 100644 index 0000000..b9c8b71 --- /dev/null +++ b/src/gdpr/gdpr_consent.rs @@ -0,0 +1,28 @@ +use crate::{GdprConsentRights, GdprConsentState, GdprValidity, UserType}; +use chrono::{DateTime, FixedOffset}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct GdprConsent { + pub id: i64, + pub person_type: UserType, + pub person_id: String, + pub created: DateTime, + pub validity: GdprValidity, + pub valid_from: DateTime, + pub state: GdprConsentState, + pub title: Option, + pub personal_data: Option, + pub usage_purpose: Option, + pub valid_to: Option>, + pub valid_years: Option, + pub rights: Option, + pub body: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct GdprConsents { + pub person_consents: Vec, +} diff --git a/src/gdpr/gdpr_consent_rights.rs b/src/gdpr/gdpr_consent_rights.rs new file mode 100644 index 0000000..6a05b9b --- /dev/null +++ b/src/gdpr/gdpr_consent_rights.rs @@ -0,0 +1,9 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct GdprConsentRights { + pub can_agree: bool, + pub can_disagree: bool, + pub can_revoke_request: bool, +} diff --git a/src/gdpr/gdpr_consent_state.rs b/src/gdpr/gdpr_consent_state.rs new file mode 100644 index 0000000..ecf60d1 --- /dev/null +++ b/src/gdpr/gdpr_consent_state.rs @@ -0,0 +1,14 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum GdprConsentState { + Agreed, + Cancelled, + Disagreed, + Expired, + NewConsent, + RevokeRequested, + Revoked, + Unknown, +} diff --git a/src/gdpr/gdpr_validity.rs b/src/gdpr/gdpr_validity.rs new file mode 100644 index 0000000..4c69ab7 --- /dev/null +++ b/src/gdpr/gdpr_validity.rs @@ -0,0 +1,11 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum GdprValidity { + EndOfStudy, + EndOfStudyPlusYears, + ToAppeal, + Unknown, + Validity, +} diff --git a/src/gdpr/mod.rs b/src/gdpr/mod.rs index 2079a5b..4495940 100644 --- a/src/gdpr/mod.rs +++ b/src/gdpr/mod.rs @@ -1,5 +1,13 @@ mod endpoints; -mod gdpr; +mod gdpr_commissioner; +mod gdpr_consent; +mod gdpr_consent_rights; +mod gdpr_consent_state; +mod gdpr_validity; pub use endpoints::*; -pub use gdpr::*; +pub use gdpr_commissioner::*; +pub use gdpr_consent::*; +pub use gdpr_consent_rights::*; +pub use gdpr_consent_state::*; +pub use gdpr_validity::*; diff --git a/src/homework/endpoints.rs b/src/homework/endpoints.rs index 586edf1..a6b3f0b 100644 --- a/src/homework/endpoints.rs +++ b/src/homework/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{Endpoint, HomeworkList}; +use std::marker::PhantomData; pub const HOMEWORKS_COUNT_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/homeworks/count-actual", diff --git a/src/homework/homeworks.rs b/src/homework/homeworks.rs index 3fea919..9962e46 100644 --- a/src/homework/homeworks.rs +++ b/src/homework/homeworks.rs @@ -1,17 +1,10 @@ +use crate::{AttachmentInfo, StdType}; use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; -use crate::{AttachmentInfo, StdType}; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] -pub struct HomeworkList { - pub homeworks: Vec, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct HomeworkListItem { +pub struct HomeworkItem { #[serde(rename = "ID")] pub id: String, pub date_start: DateTime, @@ -22,10 +15,16 @@ pub struct HomeworkListItem { pub closed: bool, pub electronic: bool, //check existance pub hour: i64, - pub class: StdType, //HomeworkSchoolClass - pub group: StdType, //HomeworkSchoolGroup - pub subject: StdType, //HomeworkSchoolSubject - pub teacher: StdType, //HomeworkTeacher + pub class: StdType, + pub group: StdType, + pub subject: StdType, + pub teacher: StdType, pub attachments: Vec, pub finished: bool, } + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct HomeworkList { + pub homeworks: Vec, +} diff --git a/src/marks/endpoints.rs b/src/marks/endpoints.rs index 5c6a55c..54dcf05 100644 --- a/src/marks/endpoints.rs +++ b/src/marks/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{ContentType, Endpoint, Marks}; +use std::marker::PhantomData; pub const CONFIRM_MARKS_ENDPOINT: Endpoint<(), Vec> = Endpoint::Post { url: "/api/3/marks/SetClassificationConfirmation", diff --git a/src/marks/mark.rs b/src/marks/mark.rs new file mode 100644 index 0000000..9eadcf8 --- /dev/null +++ b/src/marks/mark.rs @@ -0,0 +1,31 @@ +use crate::MarkConfirmationStatus; +use chrono::{DateTime, FixedOffset}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct Mark { + pub mark_date: DateTime, + pub edit_date: DateTime, + pub is_invalid_date: bool, + pub teacher_id: Option, + pub subject_id: String, + pub is_new: bool, + pub is_points: bool, + pub calculated_mark_text: String, + pub max_points: i64, + pub is_predictor_mark: bool, + pub mark_confirmation_state: MarkConfirmationStatus, + pub caption: Option, + pub theme: Option, + pub mark_text: Option, + pub r#type: Option, + pub type_note: Option, + pub weight: Option, + pub class_rank_text: Option, + pub id: Option, + pub points_text: Option, + pub confirmed_when: Option>, + pub confirmed_by: Option, + pub verbal_evaluation: Option, +} diff --git a/src/marks/mark_confirmation_status.rs b/src/marks/mark_confirmation_status.rs new file mode 100644 index 0000000..3b08491 --- /dev/null +++ b/src/marks/mark_confirmation_status.rs @@ -0,0 +1,10 @@ +pub use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum MarkConfirmationStatus { + Confirmed, + DoesNotRequireConfirmation, + Unconfirmed, + UnconfirmedAfterChange, +} diff --git a/src/marks/mod.rs b/src/marks/mod.rs index 1530cc9..aa07d14 100644 --- a/src/marks/mod.rs +++ b/src/marks/mod.rs @@ -1,5 +1,9 @@ mod endpoints; +mod mark; +mod mark_confirmation_status; mod subject_marks; pub use endpoints::*; +pub use mark::*; +pub use mark_confirmation_status::*; pub use subject_marks::*; diff --git a/src/marks/subject_marks.rs b/src/marks/subject_marks.rs index ddac43f..474d498 100644 --- a/src/marks/subject_marks.rs +++ b/src/marks/subject_marks.rs @@ -1,14 +1,6 @@ -use chrono::{DateTime, FixedOffset}; +use crate::{Mark, StdType}; use serde::{Deserialize, Serialize}; -use crate::StdType; - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct Marks { - pub subjects: Vec, -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct SubjectMarks { @@ -24,37 +16,6 @@ pub struct SubjectMarks { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] -pub struct Mark { - pub mark_date: DateTime, - pub edit_date: DateTime, - pub is_invalid_date: bool, - pub teacher_id: Option, - pub subject_id: String, - pub is_new: bool, - pub is_points: bool, - pub calculated_mark_text: String, - pub max_points: i64, - pub is_predictor_mark: bool, - pub mark_confirmation_state: MarkConfirmationStatus, - pub caption: Option, - pub theme: Option, - pub mark_text: Option, - pub r#type: Option, - pub type_note: Option, - pub weight: Option, - pub class_rank_text: Option, - pub id: Option, - pub points_text: Option, - pub confirmed_when: Option>, - pub confirmed_by: Option, - pub verbal_evaluation: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum MarkConfirmationStatus { - Confirmed, - DoesNotRequireConfirmation, - Unconfirmed, - UnconfirmedAfterChange, +pub struct Marks { + pub subjects: Vec, } diff --git a/src/others/endpoints.rs b/src/others/endpoints.rs index 7faa858..d3d361c 100644 --- a/src/others/endpoints.rs +++ b/src/others/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{ApiInfo, Endpoint}; +use std::marker::PhantomData; pub const API_V3_INFO_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3", diff --git a/src/payments/endpoints.rs b/src/payments/endpoints.rs index 9398bd0..bd1e31c 100644 --- a/src/payments/endpoints.rs +++ b/src/payments/endpoints.rs @@ -1,11 +1,10 @@ -use std::marker::PhantomData; - use crate::{ ClassFundMonthly, ClassFundPaymentInfo, ClassFundSummary, ClassFundTeacherDocumentDetail, ClassFundTeacherDocumentsMonthly, ClassFundTeacherStudentsItem, ClassFundTeacherSummary, Endpoint, RegularPayment, RegularPaymentDetail, RegularPaymentsSummary, RegularPrescription, RegularPrescriptionDetail, RegularPrescriptionStudent, RegularPrescriptionStudentDetail, }; +use std::marker::PhantomData; pub const CLASS_FUND_PAYMENT_INFO_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/payments/classfund/paymentsinfo", diff --git a/src/semester/endpoints.rs b/src/semester/endpoints.rs index c023000..2ba7988 100644 --- a/src/semester/endpoints.rs +++ b/src/semester/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{CertificateTerms, Endpoint, PedagogicalMeasures}; +use std::marker::PhantomData; pub const GET_CERTIFICATE_TERMS_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/marks/final", diff --git a/src/semester/semester.rs b/src/semester/semester.rs index cc7d2b0..d69c925 100644 --- a/src/semester/semester.rs +++ b/src/semester/semester.rs @@ -1,8 +1,7 @@ +use crate::StdTypeNullable; use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; -use crate::StdTypeNullable; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct CertificateTerms { diff --git a/src/stdtype.rs b/src/stdtype.rs index 3dd77f1..f633741 100644 --- a/src/stdtype.rs +++ b/src/stdtype.rs @@ -16,25 +16,9 @@ pub struct StdTypeNullable { pub name: Option, } -pub type SchoolClass = StdType; - -pub type StdClassGroup = StdType; - -pub type SchoolClassSet = StdType; - -pub type Teacher = StdType; - -pub type TeacherSet = StdType; - -pub type Room = StdType; - -pub type RoomSet = StdType; - -pub type Student = StdType; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] -pub struct TimetableStudent { +pub struct StdTypeAbbrevNullable { pub id: String, pub abbrev: Option, pub name: String, diff --git a/src/subjects/endpoints.rs b/src/subjects/endpoints.rs index d899928..c20f6e8 100644 --- a/src/subjects/endpoints.rs +++ b/src/subjects/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{Endpoint, Subjects}; +use std::marker::PhantomData; pub const SUBJECTS_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/subjects", diff --git a/src/substitutions/endpoints.rs b/src/substitutions/endpoints.rs index 729a6e7..5dfb790 100644 --- a/src/substitutions/endpoints.rs +++ b/src/substitutions/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{Endpoint, SubstitutionCycles, Substitutions}; +use std::marker::PhantomData; pub const SUBSTITUTIONS_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/substitutions", diff --git a/src/substitutions/substitutions.rs b/src/substitutions/substitutions.rs index 4a3e453..7c15efe 100644 --- a/src/substitutions/substitutions.rs +++ b/src/substitutions/substitutions.rs @@ -1,8 +1,7 @@ +use crate::{AtomType, Subject}; use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; -use crate::{AtomType, Subject}; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Substitutions { diff --git a/src/teaching/endpoints.rs b/src/teaching/endpoints.rs index a0f60ee..62adb5d 100644 --- a/src/teaching/endpoints.rs +++ b/src/teaching/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{Endpoint, Teaching}; +use std::marker::PhantomData; /// Subject ID = String pub const TEACHING_ENDPOINT: Endpoint = Endpoint::Get { diff --git a/src/teaching/teaching.rs b/src/teaching/teaching.rs index e182842..c65cdb8 100644 --- a/src/teaching/teaching.rs +++ b/src/teaching/teaching.rs @@ -1,8 +1,7 @@ +use crate::Subject; use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; -use crate::Subject; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Teaching { diff --git a/src/timetable/endpoints.rs b/src/timetable/endpoints.rs index 6c2cb44..b30de3d 100644 --- a/src/timetable/endpoints.rs +++ b/src/timetable/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{Endpoint, Timetable}; +use std::marker::PhantomData; pub const PERNAMENT_TIMETABLE_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/timetable/permanent", @@ -14,14 +13,12 @@ pub const PERNAMENT_TIMETABLE_CLASS_ENDPOINT: Endpoint = Endpoint _types: PhantomData, }; - pub const WEEK_TIMETABLE_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/timetable/actual", auth: true, _types: PhantomData, }; - pub const WEEK_TIMETABLE_CLASS_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/timetable/actual/class/{classId}", auth: true, diff --git a/src/timetable/mod.rs b/src/timetable/mod.rs index 151e3d2..bb2f873 100644 --- a/src/timetable/mod.rs +++ b/src/timetable/mod.rs @@ -1,5 +1,5 @@ -mod timetable; mod endpoints; +mod timetable; +pub use endpoints::*; pub use timetable::*; -pub use endpoints::*; \ No newline at end of file diff --git a/src/timetable/timetable.rs b/src/timetable/timetable.rs index 7216cda..2f8953a 100644 --- a/src/timetable/timetable.rs +++ b/src/timetable/timetable.rs @@ -1,8 +1,7 @@ +use crate::StdType; use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; -use crate::{Room, StdType, Student, Teacher}; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Timetable { @@ -11,10 +10,10 @@ pub struct Timetable { pub classes: Vec, pub groups: Vec, pub subjects: Vec, - pub rooms: Vec, - pub teachers: Vec, + pub rooms: Vec, + pub teachers: Vec, pub cycles: Vec, - pub students: Vec, + pub students: Vec, } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/src/user/endpoints.rs b/src/user/endpoints.rs index 9d4f301..a5fe383 100644 --- a/src/user/endpoints.rs +++ b/src/user/endpoints.rs @@ -1,6 +1,5 @@ -use std::marker::PhantomData; - use crate::{Endpoint, UserInfo}; +use std::marker::PhantomData; pub const USER_INFO_ENDPOINT: Endpoint = Endpoint::Get { url: "/api/3/user", diff --git a/src/user/user_info.rs b/src/user/user_info.rs index f2ea5d8..f9985c3 100644 --- a/src/user/user_info.rs +++ b/src/user/user_info.rs @@ -1,15 +1,14 @@ +use crate::{Module, StdType, user::ModulesSetting}; use serde::{Deserialize, Serialize}; -use crate::{Module, SchoolClass, user::ModulesSetting}; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct UserInfo { #[serde(rename = "UserUID")] pub user_uid: String, pub campaign_category_code: String, - pub class: Option, - pub teacher_classes: Option>, + pub class: Option, + pub teacher_classes: Option>, pub full_name: Option, pub school_organization_name: Option, pub school_type: Option, @@ -35,7 +34,7 @@ pub enum UserType { #[serde(rename_all = "PascalCase")] pub struct UserInfoStudent { pub full_name: String, - pub class: SchoolClass, + pub class: StdType, pub school_type: SchoolType, pub study_year: Option, }