added some endpoints
This commit is contained in:
18 files changed
+254
-9
No files matched your search
@@ -0,0 +1,22 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::{ContentType, Endpoint, LoginSuccess, OpenIdDiscovery, auth::login::LoginRequest};
|
||||
|
||||
pub const LOGIN_ENDPOINT: Endpoint<LoginSuccess, LoginRequest> = Endpoint::Post {
|
||||
url: "/api/login",
|
||||
auth: false,
|
||||
content_type: ContentType::Urlencoded,
|
||||
_types: PhantomData,
|
||||
};
|
||||
|
||||
pub const OPEN_ID_DISCOVERY_ENDPOINT: Endpoint<OpenIdDiscovery, ()> = Endpoint::Get {
|
||||
url: "/.well-known/openid-configuration",
|
||||
auth: false,
|
||||
_types: PhantomData,
|
||||
};
|
||||
|
||||
pub const LOGIN_TOKEN_ENDPOINT: Endpoint<String, ()> = Endpoint::Get {
|
||||
url: "/api/3/logintoken",
|
||||
auth: true,
|
||||
_types: PhantomData,
|
||||
};
|
||||
@@ -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 {
|
||||
|
||||
+5
-3
@@ -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::*;
|
||||
@@ -0,0 +1,20 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub enum Endpoint<Response, Request> {
|
||||
Get {
|
||||
url: &'static str,
|
||||
auth: bool,
|
||||
_types: PhantomData<fn() -> (Response, Request)>,
|
||||
},
|
||||
Post {
|
||||
url: &'static str,
|
||||
auth: bool,
|
||||
content_type: ContentType,
|
||||
_types: PhantomData<fn() -> (Response, Request)>,
|
||||
},
|
||||
}
|
||||
|
||||
pub enum ContentType {
|
||||
Urlencoded,
|
||||
Json,
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
mod endpoints;
|
||||
mod homework;
|
||||
|
||||
pub use endpoints::*;
|
||||
pub use homework::*;
|
||||
+6
-4
@@ -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,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::{ContentType, Endpoint, Marks};
|
||||
|
||||
pub const CONFIRM_MARKS_ENDPOINT: Endpoint<(), Vec<String>> = Endpoint::Post {
|
||||
url: "/api/3/marks/SetClassificationConfirmation",
|
||||
auth: true,
|
||||
content_type: ContentType::Json,
|
||||
_types: PhantomData,
|
||||
};
|
||||
|
||||
pub const COUNT_NEW_MARKS_ENDPOINT: Endpoint<i64, ()> = Endpoint::Get {
|
||||
url: "/api/3/marks/count-new",
|
||||
auth: true,
|
||||
_types: PhantomData,
|
||||
};
|
||||
|
||||
pub const MARKS_ENDPOINT: Endpoint<Marks, ()> = Endpoint::Get {
|
||||
url: "/api/3/marks",
|
||||
auth: true,
|
||||
_types: PhantomData,
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
mod endpoints;
|
||||
mod subject_marks;
|
||||
|
||||
pub use endpoints::*;
|
||||
pub use subject_marks::*;
|
||||
@@ -27,7 +27,7 @@ pub struct SubjectMarks {
|
||||
pub struct Mark {
|
||||
pub mark_date: DateTime<FixedOffset>,
|
||||
pub edit_date: DateTime<FixedOffset>,
|
||||
pub is_invalid_date: Option<bool>,
|
||||
pub is_invalid_date: bool,
|
||||
pub teacher_id: Option<String>,
|
||||
pub subject_id: String,
|
||||
pub is_new: bool,
|
||||
@@ -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,
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
mod endpoints;
|
||||
mod subject_types;
|
||||
|
||||
pub use endpoints::*;
|
||||
pub use subject_types::*;
|
||||
File renamed without changes.
@@ -0,0 +1,15 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::{Endpoint, UserInfo};
|
||||
|
||||
pub const USER_INFO_ENDPOINT: Endpoint<UserInfo, ()> = Endpoint::Get {
|
||||
url: "/api/3/user",
|
||||
auth: true,
|
||||
_types: PhantomData,
|
||||
};
|
||||
|
||||
pub const STUDENT_AT_SCHOOL_ENDPOINT: Endpoint<bool, ()> = Endpoint::Get {
|
||||
url: "/api/3/user/student-at-school",
|
||||
auth: true,
|
||||
_types: PhantomData,
|
||||
};
|
||||
@@ -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::*;
|
||||
Reference in new issue
Block a user