From 6236099ae18e8c33447123d0e04006a5bf2a88a9 Mon Sep 17 00:00:00 2001 From: vextrixes <113197359+vextrixes@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:15:12 +0100 Subject: [PATCH] added payment endpoints --- src/payments/endpoints.rs | 105 ++++++++++++++++++++++ src/payments/mod.rs | 5 ++ src/{ => payments}/payments.rs | 157 ++++++++++++++++++++------------- tracker.md | 26 +++--- 4 files changed, 219 insertions(+), 74 deletions(-) create mode 100644 src/payments/endpoints.rs create mode 100644 src/payments/mod.rs rename src/{ => payments}/payments.rs (60%) diff --git a/src/payments/endpoints.rs b/src/payments/endpoints.rs new file mode 100644 index 0000000..1779c11 --- /dev/null +++ b/src/payments/endpoints.rs @@ -0,0 +1,105 @@ +use std::marker::PhantomData; + +use crate::{ + ClassFundMonthly, ClassFundPaymentInfo, ClassFundSummary, ClassFundTeacherDocumentDetail, + ClassFundTeacherDocumentsMonthly, ClassFundTeacherStudentsItem, ClassFundTeacherSummary, + Endpoint, RegularPayment, RegularPaymentDetail, RegularPaymentsSummary, RegularPrescription, + RegularPrescriptionDetail, RegularPrescriptionStudent, RegularPrescriptionStudentDetail, +}; + +pub const CLASS_FUND_PAYMENT_INFO_ENDPOINT: Endpoint<(), ClassFundPaymentInfo> = Endpoint::Get { + url: "/api/3/payments/classfund/paymentsinfo", + auth: true, + _types: PhantomData, +}; + +pub const REGULAR_PAYMENTS_INFO_ENDPOINT: Endpoint<(), Vec> = Endpoint::Get { + url: "/api/3/payments/regularpayments", + auth: true, + _types: PhantomData, +}; + +pub const REGULAR_PAYMENTS_SUMMARY_ENDPOINT: Endpoint<(), RegularPaymentsSummary> = Endpoint::Get { + url: "/api/3/payments/regularpayments/summary", + auth: true, + _types: PhantomData, +}; + +pub const CLASS_FUND_INFO_ENDPOINT: Endpoint<(), Vec> = Endpoint::Get { + url: "/api/3/payments/classfund", + auth: true, + _types: PhantomData, +}; + +pub const CLASS_FUND_SUMMARY_ENDPOINT: Endpoint<(), ClassFundSummary> = Endpoint::Get { + url: "/api/3/payments/classfund/summary", + auth: true, + _types: PhantomData, +}; + +pub const REGULAR_PAYMENT_DETAIL_ENDPOINT: Endpoint<(), RegularPaymentDetail> = Endpoint::Get { + url: "/api/3/payments/regularpayments/detail/{paymentId}", + auth: true, + _types: PhantomData, +}; + +pub const CLASS_FUND_TEACHER_DOCUMENT_DETAIL_ENDPOINT: Endpoint< + (), + ClassFundTeacherDocumentDetail, +> = Endpoint::Get { + url: "/api/3/payments/classfund/teacher/document/detail/{documentId}", + auth: true, + _types: PhantomData, +}; + +pub const REGULAR_PRESCRIPTIONS_ENDPOINT: Endpoint<(), Vec> = Endpoint::Get { + url: "/api/3/payments/regularpayments/teacher/prescriptions", + auth: true, + _types: PhantomData, +}; + +pub const CLASS_FUND_TEACHER_STUDENTS_ENDPOINT: Endpoint<(), Vec> = + Endpoint::Get { + url: "/api/3/payments/classfund/teacher/students/{classId}", + auth: true, + _types: PhantomData, + }; + +pub const CLASS_FUND_TEACHER_DOCUMENTS_ENDPOINT: Endpoint< + (), + Vec, +> = Endpoint::Get { + url: "/api/3/payments/classfund/teacher/documents/{classId}", + auth: true, + _types: PhantomData, +}; + +pub const CLASS_FUND_TEACHER_SUMMARY_ENDPOINT: Endpoint<(), ClassFundTeacherSummary> = + Endpoint::Get { + url: "/api/3/payments/classfund/teacher/summary", + auth: true, + _types: PhantomData, + }; + +pub const REGULAR_PRESCRIPTION_DETAIL_ENDPOINT: Endpoint<(), RegularPrescriptionDetail> = + Endpoint::Get { + url: "/api/3/payments/regularpayments/teacher/prescriptions/{prescriptionId}", + auth: true, + _types: PhantomData, + }; + +pub const REGULAR_PRESCRIPTION_STUDENT_DETAIL_ENDPOINT: Endpoint< + (), + RegularPrescriptionStudentDetail, +> = Endpoint::Get { + url: "/api/3/payments/regularpayments/teacher/prescriptions/{prescriptionId}/students/{studentId}", + auth: true, + _types: PhantomData, +}; + +pub const REGULAR_PRESCRIPTION_STUDENTS_ENDPOINT: Endpoint<(), Vec> = + Endpoint::Get { + url: "/api/3/payments/regularpayments/teacher/prescriptions/{prescriptionId}/students", + auth: true, + _types: PhantomData, + }; diff --git a/src/payments/mod.rs b/src/payments/mod.rs new file mode 100644 index 0000000..09b0528 --- /dev/null +++ b/src/payments/mod.rs @@ -0,0 +1,5 @@ +mod endpoints; +mod payments; + +pub use endpoints::*; +pub use payments::*; diff --git a/src/payments.rs b/src/payments/payments.rs similarity index 60% rename from src/payments.rs rename to src/payments/payments.rs index ac73533..a30ad76 100644 --- a/src/payments.rs +++ b/src/payments/payments.rs @@ -12,93 +12,101 @@ pub struct ClassfundSummary { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundPaymentInfo { - instructions: Option, - bank_account: Option, - variable_symbol: Option, - specific_symbol: i64, - amount: f64, - message: Option, + pub instructions: Option, + pub bank_account: Option, + pub variable_symbol: Option, + pub specific_symbol: i64, + pub amount: f64, + pub message: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct ClassFundMonthly { + pub date: DateTime, + pub monthly_balance: f64, + pub items: Vec, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundRecord { - description: Option, - date: DateTime, - amount: f64, + pub description: Option, + pub date: DateTime, + pub amount: f64, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundSummary { - student_name_with_class: Option, - balance: f64, - spent: f64, + pub student_name_with_class: Option, + pub balance: f64, + pub spent: f64, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundTeacherDocumentDetailStudent { - full_name_with_class: Option, - amount: f64, - status: Option, //Option, enum "Active" "Canceled" + pub full_name_with_class: Option, + pub amount: f64, + pub status: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundTeacherDocumentDetail { - title: Option, - amount: f64, - date: DateTime, - student_count: i64, - students: Option>, + pub title: Option, + pub amount: f64, + pub date: DateTime, + pub student_count: i64, + pub students: Option>, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundTeacherDocumentsItem { - id: i64, - title: Option, - date: DateTime, - total_amount: f64, - amount_per_student: f64, - student_count: i64, + pub id: i64, + pub title: Option, + pub date: DateTime, + pub total_amount: f64, + pub amount_per_student: f64, + pub student_count: i64, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundTeacherDocumentsMonthly { - date: DateTime, - monthly_balance: f64, - items: Vec, + pub date: DateTime, + pub monthly_balance: f64, + pub items: Vec, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundTeacherStudentsItem { - variable_symbol: i64, - name: Option, - registration_number: Option, - balance: f64, - status: String, //PaymentsTeacherStudentStatus, enum "Active" "Canceled + pub variable_symbol: i64, + pub name: Option, + pub registration_number: Option, + pub balance: f64, + pub status: PaymentsTeacherStudentStatus, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundTeacherSummaryClass { - abbrev: Option, - class_id: Option, - balance: f64, - amount_to_pay: f64, - debtors: i64, - spent: f64, + pub abbrev: Option, + pub class_id: Option, + pub balance: f64, + pub amount_to_pay: f64, + pub debtors: i64, + pub spent: f64, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ClassFundTeacherSummary { - teacher_name: Option, - allowed_classes: Option>, + pub teacher_name: Option, + pub allowed_classes: Option>, } //------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -106,26 +114,26 @@ pub struct ClassFundTeacherSummary { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct RegularPaymentDetail { - title: Option, - due_date: DateTime, - amount: f64, - original_amount: f64, - status: String, //r16 = "BeforeDueDate", "NotPaid", "Paid", "PartiallyPaid" - bank_account: Option, - variable_symbol: Option, - specific_symbol: Option, - message: Option, + pub title: Option, + pub due_date: DateTime, + pub amount: f64, + pub original_amount: f64, + pub status: RegularPaymentStatus, + pub bank_account: Option, + pub variable_symbol: Option, + pub specific_symbol: Option, + pub message: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct RegularPayment { - payment_id: i64, - title: Option, - due_date: DateTime, - amount: f64, - status: String, //r16 = "BeforeDueDate", "NotPaid", "Paid", "PartiallyPaid" - original_amount: f64, + pub payment_id: i64, + pub title: Option, + pub due_date: DateTime, + pub amount: f64, + pub status: RegularPaymentStatus, + pub original_amount: f64, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -154,7 +162,7 @@ pub struct RegularPrescriptionDetail { pub payment_type_id: i64, pub payment_type_name: Option, pub amount: f64, - pub state: String, //r16 = "Paid", "PaidNotActive","unknown","Unpaid", "UnpaidNotActive" + pub state: RegularPrescription, pub due_date_max: DateTime, pub bank_account: Option, pub specific_symbol: Option, @@ -187,7 +195,7 @@ pub struct RegularPrescriptionStudentDetail { pub title: Option, pub balance: f64, pub total_regulation_amount: f64, - pub status: String, //PaymentsTeacherStudentStatus, enum "Active" "Canceled" + pub status: PaymentsTeacherStudentStatus, pub document_lines: Option>, pub regulation_lines: Option>, } @@ -200,7 +208,7 @@ pub struct RegularPrescriptionStudent { pub first_name: Option, pub full_name: Option, pub balance: f64, - pub status: String, //PaymentsTeacherStudentStatus, enum "Active" "Canceled" + pub status: PaymentsTeacherStudentStatus, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -211,7 +219,34 @@ pub struct RegularPrescription { pub payment_type_id: i64, pub payment_type_name: Option, pub amount: f64, - pub state: String, //PaymentsTeacherStudentStatus, enum "Active" "Canceled" + pub state: PaymentsTeacherStudentStatus, pub due_date_max: Option>, pub students_count: i64, } + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum PaymentsTeacherStudentStatus { + Active, + Canceled, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum RegularPaymentStatus { + BeforeDueDate, + NotPaid, + Paid, + PartiallyPaid, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub enum RegularPrescriptionState { + Paid, + PaidNotActive, + #[serde(rename = "unknown")] + Unknown, + Unpaid, + UnpaidNotActive, +} diff --git a/tracker.md b/tracker.md index e418479..09b0cf3 100644 --- a/tracker.md +++ b/tracker.md @@ -6,7 +6,7 @@ - [ ] class book - [x] events - [x] auth -- [ ] error +- [ ] errors - [x] gdpr - [x] homeworks - [ ] komens @@ -31,17 +31,17 @@ - [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 +- [x] /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 +- [x] /api/3/payments/classfund/teacher/document/detail/:documentId - [ ] /api/3 - [ ] /api/3/komens/attachment/:id - [x] /api/3/subjects/themes/:subjectId -- [ ] /api/3/payments/classfund +- [x] /api/3/payments/classfund - [ ] /api/3/gdpr/consents/person/child - [ ] /api/3/komens/concept/:conceptId - [ ] /api/3/marks/measures @@ -54,13 +54,13 @@ - [ ] /api/3/komens/messages/apology/:messageId - [ ] /api/3/komens/messages/received/:messageId - [x] /api/3/user -- [ ] /api/3/payments/regularpayments/detail/:paymentId +- [x] /api/3/payments/regularpayments/detail/:paymentId - [x] /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 +- [x] /api/3/payments/regularpayments/summary - [ ] /api/3/emergency/startemergency - [ ] /api/3/timetable/permanent/class/:classId - [ ] /api/3/gdpr/commissioner/send-report @@ -80,7 +80,7 @@ - [ ] /api/3/login/:token - [ ] /api/3/komens/concepts - [ ] /api/3/komens/messages/received/unread -- [ ] /api/3/payments/regularpayments/teacher/prescriptions/:prescriptionId +- [x] /api/3/payments/regularpayments/teacher/prescriptions/:prescriptionId - [ ] /api/3/timetable/actual/class/:classId - [ ] /api/3/gdpr/consents/person - [ ] /api/3/komens/messages/unread @@ -93,11 +93,11 @@ - [ ] /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/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 +- [x] /api/3/payments/regularpayments/teacher/prescriptions/:prescriptionId/students/:studentId - [ ] /api/3/marking/atoms - [ ] /api/3/absence/canexcuse/:studentId - [ ] /api/3/komens/rating-templates @@ -111,17 +111,17 @@ - [x] /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 +- [x] /api/3/payments/classfund/teacher/documents/:classId +- [x] /api/3/payments/classfund/summary - [ ] /api/3/register-notification -- [ ] /api/3/payments/classfund/paymentsinfo +- [x] /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 +- [x] /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