From 442816aa1f60dff7d2251285b5e92f4202d23e21 Mon Sep 17 00:00:00 2001 From: vextrixes <113197359+vextrixes@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:53:56 +0100 Subject: [PATCH] added enums --- src/gdpr.rs | 31 ++++++++++++++++++++++++++++--- src/lib.rs | 13 +++++++++---- src/marks.rs | 11 ++++++++++- src/substitutions.rs | 27 +++++++++++++++++++++++---- src/timetable.rs | 33 ++++++++++++++++++++++++++++++--- src/user.rs | 44 ++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 142 insertions(+), 17 deletions(-) diff --git a/src/gdpr.rs b/src/gdpr.rs index fdd2431..959f4ee 100644 --- a/src/gdpr.rs +++ b/src/gdpr.rs @@ -1,6 +1,8 @@ use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; +use crate::UserType; + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct GdprCommissioners { @@ -23,12 +25,12 @@ pub struct GdprCommissioner { #[serde(rename_all = "PascalCase")] pub struct GdprConsent { pub id: i64, - pub person_type: String, //UserType Enum "controller","parents","student","teacher" + pub person_type: UserType, pub person_id: String, pub created: DateTime, - pub validity: String, //enum "endOfStudy","endOfStudyPlusYears","toAppeal","unknown", "validity" + pub validity: GdprValidity, pub valid_from: DateTime, - pub state: String, //Enum ConsentState "agreed", "cancelled", "disagreed", "expired", "newConsent", "revokeRequested", "revoked", "unknown" + pub state: GdprConsentState, pub title: Option, pub personal_data: Option, pub usage_purpose: Option, @@ -38,6 +40,29 @@ pub struct GdprConsent { 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 { diff --git a/src/lib.rs b/src/lib.rs index 85185f8..0deb3e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,9 +25,12 @@ pub use api_info::ApiInfo; pub use attachment::AttachmentInfo; pub use error::{Error, ModelState, StringArray}; pub use events::{Event, EventTime, EventType, Events}; -pub use gdpr::{GdprCommissioner, GdprCommissioners, GdprConsent, GdprConsentRights}; +pub use gdpr::{ + GdprCommissioner, GdprCommissioners, GdprConsent, GdprConsentRights, GdprConsentState, + GdprValidity, +}; pub use homework::{HomeworkList, HomeworkListItem}; -pub use marks::{Mark, Marks, SubjectMarks}; +pub use marks::{Mark, MarkConfirmationStatus, Marks, SubjectMarks}; pub use payments::*; pub use semester::{ CertificateTerm, CertificateTerms, FinalMark, PedagogicalMeasure, PedagogicalMeasures, @@ -38,7 +41,9 @@ pub use stdtype::{ Teacher, TeacherSet, TimetableStudent, }; pub use subjects::{Subject, Subjects}; -pub use substitutions::{ChangeLessonInfo, SubstitutionChange, Substitutions}; +pub use substitutions::{ + ChangeDisplayType, ChangeLessonInfo, SubstitutionChange, SubstitutionChangeType, Substitutions, +}; pub use teaching::{Lesson, Teaching, TeachingTheme}; pub use timetable::*; -pub use user::{Module, UserInfo, UserInfoStudent}; +pub use user::{Module, UserInfo, UserInfoStudent, UserType, SchoolType}; diff --git a/src/marks.rs b/src/marks.rs index 830833f..3c02a26 100644 --- a/src/marks.rs +++ b/src/marks.rs @@ -35,7 +35,7 @@ pub struct Mark { pub calculated_mark_text: String, pub max_points: i64, pub is_predictor_mark: bool, - pub mark_confirmation_state: String, // Option enum "Confirmed", "DoesNotRequireConfirmation","Unconfirmed", "UnconfirmedAfterChange" + pub mark_confirmation_state: MarkConfirmationStatus, pub caption: Option, pub theme: Option, pub mark_text: Option, @@ -49,3 +49,12 @@ pub struct Mark { pub confirmed_by: Option, pub verbal_evaluation: Option, } + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum MarkConfirmationStatus { + Confirmed, + DoesNotRequireConfirmation, + Unconfirmed, + UnconfirmedAfterChange, +} diff --git a/src/substitutions.rs b/src/substitutions.rs index 7fada7e..359f9d2 100644 --- a/src/substitutions.rs +++ b/src/substitutions.rs @@ -1,7 +1,7 @@ use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; -use crate::Subject; +use crate::{AtomType, Subject}; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] @@ -17,12 +17,31 @@ pub struct SubstitutionChange { pub change_subject: Option, pub day: DateTime, pub hours: String, - pub change_type: String, //enum "Absence", "Added", "Canceled", "NoChange", "Removed", "RoomChanged", "Substitution" + pub change_type: SubstitutionChangeType, pub description: String, pub time: String, pub change_lesson_info: Option, - pub change_display_type: Option, //enum "OriginalTeacher", "SubstituteTeacher" - pub atom_type: Option, //enum "Hour","Pause", "TimeBlock" + pub change_display_type: Option, + pub atom_type: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum SubstitutionChangeType { + Absence, + Added, + Canceled, + NoChange, + Removed, + RoomChanged, + Substitution, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum ChangeDisplayType { + OriginalTeacher, + SubstituteTeacher, } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/src/timetable.rs b/src/timetable.rs index c361534..7216cda 100644 --- a/src/timetable.rs +++ b/src/timetable.rs @@ -22,17 +22,37 @@ pub struct Timetable { pub struct TimetableChange { pub day: DateTime, pub hours: String, - pub changetype: String, //enum "Absence", "Added", "Canceled","NoChange", "Removed", "RoomChanged", "Substitution" + pub changetype: Changetype, pub description: String, pub time: String, pub change_subject: Option, pub type_abbrev: Option, pub type_name: Option, - pub atom_type: Option, // enum "Hour", "Pause", "TimeBlock" + pub atom_type: Option, pub start: Option, pub duration: Option, } +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum Changetype { + Absence, + Added, + Canceled, + NoChange, + Removed, + RoomChanged, + Substitution, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum AtomType { + Hour, + Pause, + TimeBlock, +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct PlannedClassification { @@ -84,11 +104,18 @@ pub struct Atom { pub notice: Option, pub planned_clasification: Option, pub week_theme: Option, - pub lesson_release: String, //enum LessonRelease: "NoChange", "Released" + pub lesson_release: LessonRelease, pub start: Option, pub duration: Option, } +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum LessonRelease { + NoChange, + Released, +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Assistant { diff --git a/src/user.rs b/src/user.rs index 81912c8..f9007c7 100644 --- a/src/user.rs +++ b/src/user.rs @@ -15,7 +15,7 @@ pub struct UserInfo { pub full_name: String, //check nullable pub school_organization_name: Option, pub school_type: Option, - pub user_type: String, //Enum "controller", "parents", "student", "teacher" + pub user_type: UserType, pub user_type_text: String, pub study_year: Option, pub enabled_modules: Vec, @@ -24,6 +24,15 @@ pub struct UserInfo { pub students: Vec, } +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum UserType { + Controller, + Parents, + Student, + Teacher, +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Module { @@ -36,6 +45,37 @@ pub struct Module { pub struct UserInfoStudent { pub full_name: String, pub class: Vec, - pub school_type: String, //Enum "BasicArtSchool","BasicPracticalSchool","BasicSchool","BasicSpecialSchool","BoardingHouse","ChildrensHome","Club","Conservatory","EconomicSection","Gymnasium","HigerProfessionalSchool","Kindergarten","OtherSchool","OtherType","PracticalSchool","SchoolCanteen","SchoolClub","SchoolService","SecondarySchool","SecondaryVocationalSchool","SportGymnasium","SuperiorOrganization","TechnicalSchool","University","Unknown","VocationalSchool" + pub school_type: SchoolType, pub study_year: Option, } + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum SchoolType { + BasicArtSchool, + BasicPracticalSchool, + BasicSchool, + BasicSpecialSchool, + BoardingHouse, + ChildrensHome, + Club, + Conservatory, + EconomicSection, + Gymnasium, + HigerProfessionalSchool, + Kindergarten, + OtherSchool, + OtherType, + PracticalSchool, + SchoolCanteen, + SchoolClub, + SchoolService, + SecondarySchool, + SecondaryVocationalSchool, + SportGymnasium, + SuperiorOrganization, + TechnicalSchool, + University, + Unknown, + VocationalSchool, +}