use serde::Serialize;
pub mod absences;
pub mod announced_tests;
pub mod classes;
pub mod evaluations;
pub mod lessons;
pub mod messages;
pub mod schools;
pub mod token;
pub mod user_info;
pub trait Endpoint: std::fmt::Debug {
type Args;
fn base_url(args: impl AsRef<str>) -> String {
base::school_base(args.as_ref())
}
fn path(args: &Self::Args) -> String;
fn method() -> http::Method {
http::Method::GET
}
fn query(_input: &Self::Args) -> Vec<(&str, String)> {
Vec::new()
}
fn headers(_input: &impl Serialize) -> crate::Res<Option<http::HeaderMap>> {
Ok(None)
}
fn when(&self) -> Option<crate::LDateTime> {
None
}
}
fn opt_irval_to_query(optirval: &crate::OptIrval) -> Vec<(&'static str, String)> {
let mut q = vec![];
if let Some(from) = optirval.0 {
let from = from.and_hms_opt(0, 0, 0).unwrap().to_string();
q.push(("datumTol", from));
}
if let Some(to) = optirval.1 {
let to = to.and_hms_opt(23, 59, 59).unwrap().to_string();
q.push(("datumIg", to));
}
q
}
pub mod base {
pub const IDP: &str = "https://idp.e-kreta.hu";
pub const ADMIN: &str = "https://eugyintezes.e-kreta.hu";
pub fn school_base(school_id: impl AsRef<str>) -> String {
format!("https://{}.e-kreta.hu", school_id.as_ref()).into()
}
}