diff --git a/Cargo.lock b/Cargo.lock index 063aa42..59d1c37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,6 +92,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chrono" version = "0.4.42" @@ -341,8 +347,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasip2", + "wasm-bindgen", ] [[package]] @@ -465,6 +487,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", + "webpki-roots 0.26.11", ] [[package]] @@ -501,7 +524,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2", + "socket2 0.6.1", "system-configuration", "tokio", "tower-service", @@ -756,12 +779,12 @@ checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libft-api" -version = "0.2.0" +version = "0.1.0" dependencies = [ "chrono", "futures", "lazy_static", - "libft-api-derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libft-api-derive", "reqwest", "rsb_derive", "rvstruct", @@ -777,7 +800,7 @@ dependencies = [ [[package]] name = "libft-api-derive" -version = "0.2.0" +version = "0.1.0" dependencies = [ "proc-macro2", "quote", @@ -785,14 +808,27 @@ dependencies = [ ] [[package]] -name = "libft-api-derive" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a70586a40382d1a45bb85677436875bcd2d091db138b2042ed51557c337171" +name = "libft-api-v3-freeze" +version = "2.0.0" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", + "reqwest", + "serde", + "serde_json", + "serde_repr", + "serde_with", + "url", +] + +[[package]] +name = "libft-api-v3-pace" +version = "1.14.6" +dependencies = [ + "reqwest", + "serde", + "serde_json", + "serde_repr", + "serde_with", + "url", ] [[package]] @@ -823,6 +859,12 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + [[package]] name = "memchr" version = "2.7.4" @@ -835,6 +877,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.8.0" @@ -1008,6 +1060,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + [[package]] name = "proc-macro2" version = "1.0.101" @@ -1017,6 +1078,61 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626214629cda6781b6dc1d316ba307189c85ba657213ce642d9c77670f8202c8" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2 0.5.10", + "thiserror", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e" +dependencies = [ + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcebb1209ee276352ef14ff8732e24cc2b02bbac986cd74a4c81bcb2f9881970" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2 0.5.10", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.41" @@ -1026,6 +1142,41 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.4", +] + [[package]] name = "redox_syscall" version = "0.5.8" @@ -1065,6 +1216,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-core", + "futures-util", "h2", "http", "http-body", @@ -1076,9 +1228,12 @@ dependencies = [ "js-sys", "log", "mime", + "mime_guess", "native-tls", "percent-encoding", "pin-project-lite", + "quinn", + "rustls", "rustls-pki-types", "serde", "serde_json", @@ -1086,6 +1241,7 @@ dependencies = [ "sync_wrapper", "tokio", "tokio-native-tls", + "tokio-rustls", "tower", "tower-http", "tower-service", @@ -1093,6 +1249,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 1.0.2", ] [[package]] @@ -1103,7 +1260,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", "spin", "untrusted", @@ -1127,6 +1284,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + [[package]] name = "rustix" version = "0.38.42" @@ -1147,6 +1310,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" dependencies = [ "once_cell", + "ring", "rustls-pki-types", "rustls-webpki", "subtle", @@ -1158,6 +1322,9 @@ name = "rustls-pki-types" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -1316,6 +1483,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1398,6 +1576,16 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "socket2" version = "0.6.1" @@ -1508,6 +1696,26 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -1559,6 +1767,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.47.1" @@ -1574,7 +1797,7 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "slab", - "socket2", + "socket2 0.6.1", "tokio-macros", "tracing", "windows-sys 0.59.0", @@ -1732,6 +1955,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + [[package]] name = "unicode-ident" version = "1.0.14" @@ -1795,6 +2024,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasip2" +version = "1.0.0+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.104" @@ -1877,6 +2115,34 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.2", +] + +[[package]] +name = "webpki-roots" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -2083,6 +2349,12 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" +[[package]] +name = "wit-bindgen" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36" + [[package]] name = "write16" version = "1.0.0" @@ -2119,6 +2391,26 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zerocopy" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "zerofrom" version = "0.1.5" diff --git a/Cargo.toml b/Cargo.toml index f8fc9fa..6d5f528 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = [ - "libft-api", "libft-api-derive", + "libft-api", "libft-api-derive", "libft-api-v3", "libft-api-v3-pace" ] resolver = "2" diff --git a/libft-api-v3-pace/Cargo.toml b/libft-api-v3-pace/Cargo.toml new file mode 100644 index 0000000..d88c549 --- /dev/null +++ b/libft-api-v3-pace/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "libft-api-v3-pace" +version = "1.14.6" +authors = ["OpenAPI Generator team and contributors"] +description = "Pace and milestone management" +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2021" + +[dependencies] +serde = { version = "^1.0", features = ["derive"] } +serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] } +serde_json = "^1.0" +serde_repr = "^0.1" +url = "^2.5" +reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart"] } + +[features] +default = ["native-tls"] +native-tls = ["reqwest/native-tls"] +rustls-tls = ["reqwest/rustls-tls"] diff --git a/libft-api-v3-pace/src/apis/campus_api.rs b/libft-api-v3-pace/src/apis/campus_api.rs new file mode 100644 index 0000000..9fbab3a --- /dev/null +++ b/libft-api-v3-pace/src/apis/campus_api.rs @@ -0,0 +1,273 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`delete_campus_webhook_campus_campus_id_webhook_delete`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteCampusWebhookCampusCampusIdWebhookDeleteError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_campus_by_id_campus_campus_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCampusByIdCampusCampusIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_campuses_campus_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListCampusesCampusGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_campus_campus_campus_id_patch`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateCampusCampusCampusIdPatchError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_campus_webhook_campus_campus_id_webhook_patch`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateCampusWebhookCampusCampusIdWebhookPatchError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + + +/// Delete specific `Campus` webhook +pub async fn delete_campus_webhook_campus_campus_id_webhook_delete(configuration: &configuration::Configuration, campus_id: i32) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_campus_id = campus_id; + + let uri_str = format!("{}/campus/{campus_id}/webhook", configuration.base_path, campus_id=p_path_campus_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Retrieve specific `Campus` +pub async fn get_campus_by_id_campus_campus_id_get(configuration: &configuration::Configuration, campus_id: i32) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_campus_id = campus_id; + + let uri_str = format!("{}/campus/{campus_id}", configuration.base_path, campus_id=p_path_campus_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// List all `Campus` entities +pub async fn list_campuses_campus_get(configuration: &configuration::Configuration, page: Option, size: Option, all: Option) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_page = page; + let p_query_size = size; + let p_query_all = all; + + let uri_str = format!("{}/campus/", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_all { + req_builder = req_builder.query(&[("all", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageCampus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageCampus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Update specific `Campus` +pub async fn update_campus_campus_campus_id_patch(configuration: &configuration::Configuration, campus_id: i32, update_campus: models::UpdateCampus) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_campus_id = campus_id; + let p_body_update_campus = update_campus; + + let uri_str = format!("{}/campus/{campus_id}", configuration.base_path, campus_id=p_path_campus_id); + let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_body_update_campus); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Update specific `Campus` webhook +pub async fn update_campus_webhook_campus_campus_id_webhook_patch(configuration: &configuration::Configuration, campus_id: i32, update_campus: models::UpdateCampus) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_campus_id = campus_id; + let p_body_update_campus = update_campus; + + let uri_str = format!("{}/campus/{campus_id}/webhook", configuration.base_path, campus_id=p_path_campus_id); + let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_body_update_campus); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/libft-api-v3-pace/src/apis/configuration.rs b/libft-api-v3-pace/src/apis/configuration.rs new file mode 100644 index 0000000..ac01a05 --- /dev/null +++ b/libft-api-v3-pace/src/apis/configuration.rs @@ -0,0 +1,48 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "/api/v1".to_owned(), + user_agent: Some("OpenAPI-Generator/1.14.6/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/libft-api-v3-pace/src/apis/milestones_api.rs b/libft-api-v3-pace/src/apis/milestones_api.rs new file mode 100644 index 0000000..6f05b79 --- /dev/null +++ b/libft-api-v3-pace/src/apis/milestones_api.rs @@ -0,0 +1,125 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`retrieve_all_milestones_milestones_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveAllMilestonesMilestonesGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`retrieve_milestone_by_id_milestones_milestone_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveMilestoneByIdMilestonesMilestoneIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + + +/// List all `Milestones` entities +pub async fn retrieve_all_milestones_milestones_get(configuration: &configuration::Configuration, page: Option, size: Option, all: Option) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_page = page; + let p_query_size = size; + let p_query_all = all; + + let uri_str = format!("{}/milestones", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_all { + req_builder = req_builder.query(&[("all", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageMilestone`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageMilestone`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Retrieve a specific `Milestone` entity +pub async fn retrieve_milestone_by_id_milestones_milestone_id_get(configuration: &configuration::Configuration, milestone_id: i32) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_milestone_id = milestone_id; + + let uri_str = format!("{}/milestones/{milestone_id}", configuration.base_path, milestone_id=p_path_milestone_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Milestone`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Milestone`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/libft-api-v3-pace/src/apis/mod.rs b/libft-api-v3-pace/src/apis/mod.rs new file mode 100644 index 0000000..89af2f0 --- /dev/null +++ b/libft-api-v3-pace/src/apis/mod.rs @@ -0,0 +1,120 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + }, + serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())), + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +/// Internal use only +/// A content type supported by this client. +#[allow(dead_code)] +enum ContentType { + Json, + Text, + Unsupported(String) +} + +impl From<&str> for ContentType { + fn from(content_type: &str) -> Self { + if content_type.starts_with("application") && content_type.contains("json") { + return Self::Json; + } else if content_type.starts_with("text/plain") { + return Self::Text; + } else { + return Self::Unsupported(content_type.to_string()); + } + } +} + +pub mod campus_api; +pub mod milestones_api; +pub mod pace_matrix_api; +pub mod paces_api; +pub mod users_api; + +pub mod configuration; diff --git a/libft-api-v3-pace/src/apis/pace_matrix_api.rs b/libft-api-v3-pace/src/apis/pace_matrix_api.rs new file mode 100644 index 0000000..5bf33cb --- /dev/null +++ b/libft-api-v3-pace/src/apis/pace_matrix_api.rs @@ -0,0 +1,233 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`create_pace_matrix_pace_matrix_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreatePaceMatrixPaceMatrixPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_pace_matrix_by_version_pace_matrix_version_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPaceMatrixByVersionPaceMatrixVersionIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_pace_matrix_cells_pace_matrix_cells_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListPaceMatrixCellsPaceMatrixCellsGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_pace_matrix_versions_pace_matrix_versions_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListPaceMatrixVersionsPaceMatrixVersionsGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + + +/// Create a `PaceMatrix` entity +pub async fn create_pace_matrix_pace_matrix_post(configuration: &configuration::Configuration, pace_matrix_creation: models::PaceMatrixCreation) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_pace_matrix_creation = pace_matrix_creation; + + let uri_str = format!("{}/pace_matrix", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_body_pace_matrix_creation); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaceMatrix`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaceMatrix`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Retrieve specific `PaceMatrix` entity +pub async fn get_pace_matrix_by_version_pace_matrix_version_id_get(configuration: &configuration::Configuration, version_id: i32) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_version_id = version_id; + + let uri_str = format!("{}/pace_matrix/{version_id}", configuration.base_path, version_id=p_path_version_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaceMatrix`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaceMatrix`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// List all `PaceMatrixVersionedCell` entities +pub async fn list_pace_matrix_cells_pace_matrix_cells_get(configuration: &configuration::Configuration, page: Option, size: Option, all: Option) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_page = page; + let p_query_size = size; + let p_query_all = all; + + let uri_str = format!("{}/pace_matrix/cells", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_all { + req_builder = req_builder.query(&[("all", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagePaceMatrixVersionedCell`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagePaceMatrixVersionedCell`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// List all `PaceMatrixVersion` entities +pub async fn list_pace_matrix_versions_pace_matrix_versions_get(configuration: &configuration::Configuration, page: Option, size: Option, all: Option) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_page = page; + let p_query_size = size; + let p_query_all = all; + + let uri_str = format!("{}/pace_matrix/versions", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_all { + req_builder = req_builder.query(&[("all", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagePaceMatrixVersion`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagePaceMatrixVersion`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/libft-api-v3-pace/src/apis/paces_api.rs b/libft-api-v3-pace/src/apis/paces_api.rs new file mode 100644 index 0000000..1deb4a9 --- /dev/null +++ b/libft-api-v3-pace/src/apis/paces_api.rs @@ -0,0 +1,125 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`retrieve_all_paces_paces_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrieveAllPacesPacesGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`retrieve_pace_by_id_paces_pace_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RetrievePaceByIdPacesPaceIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + + +/// List all `Pace` entities +pub async fn retrieve_all_paces_paces_get(configuration: &configuration::Configuration, page: Option, size: Option, all: Option) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_page = page; + let p_query_size = size; + let p_query_all = all; + + let uri_str = format!("{}/paces", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_all { + req_builder = req_builder.query(&[("all", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagePace`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagePace`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Retrieve specific `Pace` entity +pub async fn retrieve_pace_by_id_paces_pace_id_get(configuration: &configuration::Configuration, pace_id: i32) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_pace_id = pace_id; + + let uri_str = format!("{}/paces/{pace_id}", configuration.base_path, pace_id=p_path_pace_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pace`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pace`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/libft-api-v3-pace/src/apis/users_api.rs b/libft-api-v3-pace/src/apis/users_api.rs new file mode 100644 index 0000000..0816672 --- /dev/null +++ b/libft-api-v3-pace/src/apis/users_api.rs @@ -0,0 +1,556 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`activate_user_users_user_id_activate_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActivateUserUsersUserIdActivatePostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_authenticated_user_informations_users_me_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAuthenticatedUserInformationsUsersMeGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_user_by_id_users_user_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetUserByIdUsersUserIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_user_profile_users_user_id_profile_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetUserProfileUsersUserIdProfileGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_authenticated_user_milestones_users_me_milestones_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListAuthenticatedUserMilestonesUsersMeMilestonesGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_authenticated_user_paces_users_me_paces_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListAuthenticatedUserPacesUsersMePacesGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_user_milestones_users_user_id_milestones_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListUserMilestonesUsersUserIdMilestonesGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_user_paces_users_user_id_paces_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListUserPacesUsersUserIdPacesGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_users_users_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListUsersUsersGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`pace_speed_up_users_me_pace_speed_up_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PaceSpeedUpUsersMePaceSpeedUpPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`set_authenticated_user_initial_pace_users_me_initial_pace_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SetAuthenticatedUserInitialPaceUsersMeInitialPacePostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + + +/// Activates user, or returns a report of what the user would look like when they are activated (`dry_run` filed in `options`) Options params: - `dry_run`: does NOT activate the user, and print what the state of the user would be if they were activated, plus some alternative steps - `activation_date`: allows to set an activation date in the future (instead of using `date.today()`). Only available with `dry_run`. `activation_date` - `date.today()` days will be added to deadline (via `cumulative_freeze_days`) - `bypass_intra_v2_blackhole`: allows to not take into account the Intra v2 blackhole when computing deadlines. - `max_pace`: allows to change the maximum pace level the user can be activated at. Return: - activated user data (`User`) - dry run infos of user (`UserActivationDryRunOutput`) +pub async fn activate_user_users_user_id_activate_post(configuration: &configuration::Configuration, user_id: i32, user_activation_options: models::UserActivationOptions) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + let p_body_user_activation_options = user_activation_options; + + let uri_str = format!("{}/users/{user_id}/activate", configuration.base_path, user_id=p_path_user_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_body_user_activation_options); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResponseActivateUserUsersUserIdActivatePost`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ResponseActivateUserUsersUserIdActivatePost`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Retrieve the informations of the authenticated `User` +pub async fn get_authenticated_user_informations_users_me_get(configuration: &configuration::Configuration, ) -> Result> { + + let uri_str = format!("{}/users/me", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Retrieve specific `User` +pub async fn get_user_by_id_users_user_id_get(configuration: &configuration::Configuration, user_id: i32) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + + let uri_str = format!("{}/users/{user_id}", configuration.base_path, user_id=p_path_user_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Returns a `UserProfile` object that contains \"non sensible\" user data. This route is accessible to any authenticated staff or student. +pub async fn get_user_profile_users_user_id_profile_get(configuration: &configuration::Configuration, user_id: i32) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + + let uri_str = format!("{}/users/{user_id}/profile", configuration.base_path, user_id=p_path_user_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserProfile`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserProfile`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// List the `Milestones` of the current authenticated `User` +pub async fn list_authenticated_user_milestones_users_me_milestones_get(configuration: &configuration::Configuration, ) -> Result, Error> { + + let uri_str = format!("{}/users/me/milestones", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UserMilestoneValidation>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::UserMilestoneValidation>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// List the `Paces` of the current authenticated `User` +pub async fn list_authenticated_user_paces_users_me_paces_get(configuration: &configuration::Configuration, ) -> Result, Error> { + + let uri_str = format!("{}/users/me/paces", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pace>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pace>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// List all `Milestone` entities from specific `User` This route is accessible to any authenticated staff or student +pub async fn list_user_milestones_users_user_id_milestones_get(configuration: &configuration::Configuration, user_id: i32) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + + let uri_str = format!("{}/users/{user_id}/milestones", configuration.base_path, user_id=p_path_user_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UserMilestoneValidation>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::UserMilestoneValidation>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// List all `Pace` entities from specific `User`. This route is accessible to any authenticated staff or student +pub async fn list_user_paces_users_user_id_paces_get(configuration: &configuration::Configuration, user_id: i32) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_id = user_id; + + let uri_str = format!("{}/users/{user_id}/paces", configuration.base_path, user_id=p_path_user_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pace>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pace>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// List all `User` entities +pub async fn list_users_users_get(configuration: &configuration::Configuration, is_active: Option, page: Option, size: Option, all: Option) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_is_active = is_active; + let p_query_page = page; + let p_query_size = size; + let p_query_all = all; + + let uri_str = format!("{}/users", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_is_active { + req_builder = req_builder.query(&[("is_active", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_query_all { + req_builder = req_builder.query(&[("all", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageUser`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Allow the current authenticated `User` to pace speed up +pub async fn pace_speed_up_users_me_pace_speed_up_post(configuration: &configuration::Configuration, speed_up_body: models::SpeedUpBody) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_speed_up_body = speed_up_body; + + let uri_str = format!("{}/users/me/pace_speed_up", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_body_speed_up_body); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Set the inital `Pace` of the current authenticated `User` +pub async fn set_authenticated_user_initial_pace_users_me_initial_pace_post(configuration: &configuration::Configuration, initial_pace_form: models::InitialPaceForm) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_initial_pace_form = initial_pace_form; + + let uri_str = format!("{}/users/me/initial_pace", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_body_initial_pace_form); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/libft-api-v3-pace/src/lib.rs b/libft-api-v3-pace/src/lib.rs new file mode 100644 index 0000000..e152062 --- /dev/null +++ b/libft-api-v3-pace/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde_repr; +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/libft-api-v3-pace/src/models/campus.rs b/libft-api-v3-pace/src/models/campus.rs new file mode 100644 index 0000000..1693845 --- /dev/null +++ b/libft-api-v3-pace/src/models/campus.rs @@ -0,0 +1,48 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Campus { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "display_name")] + pub display_name: String, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "timezone")] + pub timezone: String, + #[serde(rename = "is_activated", skip_serializing_if = "Option::is_none")] + pub is_activated: Option, + #[serde(rename = "is_kickoff_activated", skip_serializing_if = "Option::is_none")] + pub is_kickoff_activated: Option, + #[serde(rename = "webhook_uri", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub webhook_uri: Option>, + #[serde(rename = "webhook_secret", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub webhook_secret: Option>, +} + +impl Campus { + pub fn new(id: i32, display_name: String, name: String, timezone: String) -> Campus { + Campus { + id, + display_name, + name, + timezone, + is_activated: None, + is_kickoff_activated: None, + webhook_uri: None, + webhook_secret: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/http_validation_error.rs b/libft-api-v3-pace/src/models/http_validation_error.rs new file mode 100644 index 0000000..8fb0f5b --- /dev/null +++ b/libft-api-v3-pace/src/models/http_validation_error.rs @@ -0,0 +1,27 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct HttpValidationError { + #[serde(rename = "detail", skip_serializing_if = "Option::is_none")] + pub detail: Option>, +} + +impl HttpValidationError { + pub fn new() -> HttpValidationError { + HttpValidationError { + detail: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/initial_pace_form.rs b/libft-api-v3-pace/src/models/initial_pace_form.rs new file mode 100644 index 0000000..59a9949 --- /dev/null +++ b/libft-api-v3-pace/src/models/initial_pace_form.rs @@ -0,0 +1,27 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct InitialPaceForm { + #[serde(rename = "selected_pace")] + pub selected_pace: i32, +} + +impl InitialPaceForm { + pub fn new(selected_pace: i32) -> InitialPaceForm { + InitialPaceForm { + selected_pace, + } + } +} + diff --git a/libft-api-v3-pace/src/models/milestone.rs b/libft-api-v3-pace/src/models/milestone.rs new file mode 100644 index 0000000..8eb2785 --- /dev/null +++ b/libft-api-v3-pace/src/models/milestone.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Milestone { + #[serde(rename = "id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub id: Option>, + #[serde(rename = "level")] + pub level: i32, + #[serde(rename = "deadline", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub deadline: Option>, + #[serde(rename = "validated_at")] + pub validated_at: String, + #[serde(rename = "user_id")] + pub user_id: i32, +} + +impl Milestone { + pub fn new(level: i32, validated_at: String, user_id: i32) -> Milestone { + Milestone { + id: None, + level, + deadline: None, + validated_at, + user_id, + } + } +} + diff --git a/libft-api-v3-pace/src/models/mod.rs b/libft-api-v3-pace/src/models/mod.rs new file mode 100644 index 0000000..69dbedc --- /dev/null +++ b/libft-api-v3-pace/src/models/mod.rs @@ -0,0 +1,56 @@ +pub mod campus; +pub use self::campus::Campus; +pub mod http_validation_error; +pub use self::http_validation_error::HttpValidationError; +pub mod initial_pace_form; +pub use self::initial_pace_form::InitialPaceForm; +pub mod milestone; +pub use self::milestone::Milestone; +pub mod pace; +pub use self::pace::Pace; +pub mod pace_matrix; +pub use self::pace_matrix::PaceMatrix; +pub mod pace_matrix_cell; +pub use self::pace_matrix_cell::PaceMatrixCell; +pub mod pace_matrix_creation; +pub use self::pace_matrix_creation::PaceMatrixCreation; +pub mod pace_matrix_version; +pub use self::pace_matrix_version::PaceMatrixVersion; +pub mod pace_matrix_version_creation; +pub use self::pace_matrix_version_creation::PaceMatrixVersionCreation; +pub mod pace_matrix_versioned_cell; +pub use self::pace_matrix_versioned_cell::PaceMatrixVersionedCell; +pub mod pace_speed_up; +pub use self::pace_speed_up::PaceSpeedUp; +pub mod page_campus_; +pub use self::page_campus_::PageCampus; +pub mod page_milestone_; +pub use self::page_milestone_::PageMilestone; +pub mod page_pace_; +pub use self::page_pace_::PagePace; +pub mod page_pace_matrix_version_; +pub use self::page_pace_matrix_version_::PagePaceMatrixVersion; +pub mod page_pace_matrix_versioned_cell_; +pub use self::page_pace_matrix_versioned_cell_::PagePaceMatrixVersionedCell; +pub mod page_user_; +pub use self::page_user_::PageUser; +pub mod response_activate_user_users__user_id__activate_post; +pub use self::response_activate_user_users__user_id__activate_post::ResponseActivateUserUsersUserIdActivatePost; +pub mod speed_up_body; +pub use self::speed_up_body::SpeedUpBody; +pub mod update_campus; +pub use self::update_campus::UpdateCampus; +pub mod user; +pub use self::user::User; +pub mod user_activation_dry_run_output; +pub use self::user_activation_dry_run_output::UserActivationDryRunOutput; +pub mod user_activation_options; +pub use self::user_activation_options::UserActivationOptions; +pub mod user_milestone_validation; +pub use self::user_milestone_validation::UserMilestoneValidation; +pub mod user_profile; +pub use self::user_profile::UserProfile; +pub mod validation_error; +pub use self::validation_error::ValidationError; +pub mod validation_error_loc_inner; +pub use self::validation_error_loc_inner::ValidationErrorLocInner; diff --git a/libft-api-v3-pace/src/models/pace.rs b/libft-api-v3-pace/src/models/pace.rs new file mode 100644 index 0000000..cc49174 --- /dev/null +++ b/libft-api-v3-pace/src/models/pace.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Pace { + #[serde(rename = "id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub id: Option>, + #[serde(rename = "level", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub level: Option>, + #[serde(rename = "created_at")] + pub created_at: String, + #[serde(rename = "reason")] + pub reason: String, + #[serde(rename = "user_id")] + pub user_id: i32, +} + +impl Pace { + pub fn new(created_at: String, reason: String, user_id: i32) -> Pace { + Pace { + id: None, + level: None, + created_at, + reason, + user_id, + } + } +} + diff --git a/libft-api-v3-pace/src/models/pace_matrix.rs b/libft-api-v3-pace/src/models/pace_matrix.rs new file mode 100644 index 0000000..f701035 --- /dev/null +++ b/libft-api-v3-pace/src/models/pace_matrix.rs @@ -0,0 +1,32 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PaceMatrix : Class representing a pace matrix, which facilitate the manipulation of the matrix cells and data. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PaceMatrix { + #[serde(rename = "version")] + pub version: Box, + #[serde(rename = "cells")] + pub cells: Vec, +} + +impl PaceMatrix { + /// Class representing a pace matrix, which facilitate the manipulation of the matrix cells and data. + pub fn new(version: models::PaceMatrixVersion, cells: Vec) -> PaceMatrix { + PaceMatrix { + version: Box::new(version), + cells, + } + } +} + diff --git a/libft-api-v3-pace/src/models/pace_matrix_cell.rs b/libft-api-v3-pace/src/models/pace_matrix_cell.rs new file mode 100644 index 0000000..e18da3e --- /dev/null +++ b/libft-api-v3-pace/src/models/pace_matrix_cell.rs @@ -0,0 +1,35 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PaceMatrixCell : Representation of matrix data: for a given pace level and matrix level, gives the corresponding days. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PaceMatrixCell { + #[serde(rename = "milestone")] + pub milestone: i32, + #[serde(rename = "pace")] + pub pace: i32, + #[serde(rename = "days")] + pub days: i32, +} + +impl PaceMatrixCell { + /// Representation of matrix data: for a given pace level and matrix level, gives the corresponding days. + pub fn new(milestone: i32, pace: i32, days: i32) -> PaceMatrixCell { + PaceMatrixCell { + milestone, + pace, + days, + } + } +} + diff --git a/libft-api-v3-pace/src/models/pace_matrix_creation.rs b/libft-api-v3-pace/src/models/pace_matrix_creation.rs new file mode 100644 index 0000000..8ec9858 --- /dev/null +++ b/libft-api-v3-pace/src/models/pace_matrix_creation.rs @@ -0,0 +1,30 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PaceMatrixCreation { + #[serde(rename = "version")] + pub version: Box, + #[serde(rename = "cells")] + pub cells: Vec, +} + +impl PaceMatrixCreation { + pub fn new(version: models::PaceMatrixVersionCreation, cells: Vec) -> PaceMatrixCreation { + PaceMatrixCreation { + version: Box::new(version), + cells, + } + } +} + diff --git a/libft-api-v3-pace/src/models/pace_matrix_version.rs b/libft-api-v3-pace/src/models/pace_matrix_version.rs new file mode 100644 index 0000000..00d9e14 --- /dev/null +++ b/libft-api-v3-pace/src/models/pace_matrix_version.rs @@ -0,0 +1,35 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PaceMatrixVersion : Entity used to version the pace matrix (or rather it's cells) +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PaceMatrixVersion { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")] + pub created_at: Option, + #[serde(rename = "name")] + pub name: String, +} + +impl PaceMatrixVersion { + /// Entity used to version the pace matrix (or rather it's cells) + pub fn new(id: i32, name: String) -> PaceMatrixVersion { + PaceMatrixVersion { + id, + created_at: None, + name, + } + } +} + diff --git a/libft-api-v3-pace/src/models/pace_matrix_version_creation.rs b/libft-api-v3-pace/src/models/pace_matrix_version_creation.rs new file mode 100644 index 0000000..e09ef68 --- /dev/null +++ b/libft-api-v3-pace/src/models/pace_matrix_version_creation.rs @@ -0,0 +1,30 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PaceMatrixVersionCreation { + #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")] + pub created_at: Option, + #[serde(rename = "name")] + pub name: String, +} + +impl PaceMatrixVersionCreation { + pub fn new(name: String) -> PaceMatrixVersionCreation { + PaceMatrixVersionCreation { + created_at: None, + name, + } + } +} + diff --git a/libft-api-v3-pace/src/models/pace_matrix_versioned_cell.rs b/libft-api-v3-pace/src/models/pace_matrix_versioned_cell.rs new file mode 100644 index 0000000..79c63e2 --- /dev/null +++ b/libft-api-v3-pace/src/models/pace_matrix_versioned_cell.rs @@ -0,0 +1,36 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PaceMatrixVersionedCell { + #[serde(rename = "milestone")] + pub milestone: i32, + #[serde(rename = "pace")] + pub pace: i32, + #[serde(rename = "days")] + pub days: i32, + #[serde(rename = "version_id")] + pub version_id: i32, +} + +impl PaceMatrixVersionedCell { + pub fn new(milestone: i32, pace: i32, days: i32, version_id: i32) -> PaceMatrixVersionedCell { + PaceMatrixVersionedCell { + milestone, + pace, + days, + version_id, + } + } +} + diff --git a/libft-api-v3-pace/src/models/pace_speed_up.rs b/libft-api-v3-pace/src/models/pace_speed_up.rs new file mode 100644 index 0000000..8620281 --- /dev/null +++ b/libft-api-v3-pace/src/models/pace_speed_up.rs @@ -0,0 +1,30 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PaceSpeedUp { + #[serde(rename = "deadline")] + pub deadline: String, + #[serde(rename = "common_core_eta_completion")] + pub common_core_eta_completion: String, +} + +impl PaceSpeedUp { + pub fn new(deadline: String, common_core_eta_completion: String) -> PaceSpeedUp { + PaceSpeedUp { + deadline, + common_core_eta_completion, + } + } +} + diff --git a/libft-api-v3-pace/src/models/page_campus_.rs b/libft-api-v3-pace/src/models/page_campus_.rs new file mode 100644 index 0000000..d3a50c9 --- /dev/null +++ b/libft-api-v3-pace/src/models/page_campus_.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageCampus { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total", deserialize_with = "Option::deserialize")] + pub total: Option, + #[serde(rename = "page", deserialize_with = "Option::deserialize")] + pub page: Option, + #[serde(rename = "size", deserialize_with = "Option::deserialize")] + pub size: Option, + #[serde(rename = "pages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pages: Option>, +} + +impl PageCampus { + pub fn new(items: Vec, total: Option, page: Option, size: Option) -> PageCampus { + PageCampus { + items, + total, + page, + size, + pages: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/page_milestone_.rs b/libft-api-v3-pace/src/models/page_milestone_.rs new file mode 100644 index 0000000..f666492 --- /dev/null +++ b/libft-api-v3-pace/src/models/page_milestone_.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageMilestone { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total", deserialize_with = "Option::deserialize")] + pub total: Option, + #[serde(rename = "page", deserialize_with = "Option::deserialize")] + pub page: Option, + #[serde(rename = "size", deserialize_with = "Option::deserialize")] + pub size: Option, + #[serde(rename = "pages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pages: Option>, +} + +impl PageMilestone { + pub fn new(items: Vec, total: Option, page: Option, size: Option) -> PageMilestone { + PageMilestone { + items, + total, + page, + size, + pages: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/page_pace_.rs b/libft-api-v3-pace/src/models/page_pace_.rs new file mode 100644 index 0000000..7c433a1 --- /dev/null +++ b/libft-api-v3-pace/src/models/page_pace_.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PagePace { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total", deserialize_with = "Option::deserialize")] + pub total: Option, + #[serde(rename = "page", deserialize_with = "Option::deserialize")] + pub page: Option, + #[serde(rename = "size", deserialize_with = "Option::deserialize")] + pub size: Option, + #[serde(rename = "pages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pages: Option>, +} + +impl PagePace { + pub fn new(items: Vec, total: Option, page: Option, size: Option) -> PagePace { + PagePace { + items, + total, + page, + size, + pages: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/page_pace_matrix_version_.rs b/libft-api-v3-pace/src/models/page_pace_matrix_version_.rs new file mode 100644 index 0000000..4081d2e --- /dev/null +++ b/libft-api-v3-pace/src/models/page_pace_matrix_version_.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PagePaceMatrixVersion { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total", deserialize_with = "Option::deserialize")] + pub total: Option, + #[serde(rename = "page", deserialize_with = "Option::deserialize")] + pub page: Option, + #[serde(rename = "size", deserialize_with = "Option::deserialize")] + pub size: Option, + #[serde(rename = "pages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pages: Option>, +} + +impl PagePaceMatrixVersion { + pub fn new(items: Vec, total: Option, page: Option, size: Option) -> PagePaceMatrixVersion { + PagePaceMatrixVersion { + items, + total, + page, + size, + pages: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/page_pace_matrix_versioned_cell_.rs b/libft-api-v3-pace/src/models/page_pace_matrix_versioned_cell_.rs new file mode 100644 index 0000000..670a956 --- /dev/null +++ b/libft-api-v3-pace/src/models/page_pace_matrix_versioned_cell_.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PagePaceMatrixVersionedCell { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total", deserialize_with = "Option::deserialize")] + pub total: Option, + #[serde(rename = "page", deserialize_with = "Option::deserialize")] + pub page: Option, + #[serde(rename = "size", deserialize_with = "Option::deserialize")] + pub size: Option, + #[serde(rename = "pages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pages: Option>, +} + +impl PagePaceMatrixVersionedCell { + pub fn new(items: Vec, total: Option, page: Option, size: Option) -> PagePaceMatrixVersionedCell { + PagePaceMatrixVersionedCell { + items, + total, + page, + size, + pages: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/page_user_.rs b/libft-api-v3-pace/src/models/page_user_.rs new file mode 100644 index 0000000..7d5f912 --- /dev/null +++ b/libft-api-v3-pace/src/models/page_user_.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageUser { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total", deserialize_with = "Option::deserialize")] + pub total: Option, + #[serde(rename = "page", deserialize_with = "Option::deserialize")] + pub page: Option, + #[serde(rename = "size", deserialize_with = "Option::deserialize")] + pub size: Option, + #[serde(rename = "pages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pages: Option>, +} + +impl PageUser { + pub fn new(items: Vec, total: Option, page: Option, size: Option) -> PageUser { + PageUser { + items, + total, + page, + size, + pages: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/response_activate_user_users__user_id__activate_post.rs b/libft-api-v3-pace/src/models/response_activate_user_users__user_id__activate_post.rs new file mode 100644 index 0000000..d33c9cc --- /dev/null +++ b/libft-api-v3-pace/src/models/response_activate_user_users__user_id__activate_post.rs @@ -0,0 +1,114 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ResponseActivateUserUsersUserIdActivatePost { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "login", skip_serializing_if = "Option::is_none")] + pub login: Option, + #[serde(rename = "cursus_begin_date")] + pub cursus_begin_date: String, + #[serde(rename = "matrix_version")] + pub matrix_version: i32, + #[serde(rename = "campus_id")] + pub campus_id: i32, + #[serde(rename = "pace", skip_serializing_if = "Option::is_none")] + pub pace: Option, + #[serde(rename = "milestone", skip_serializing_if = "Option::is_none")] + pub milestone: Option, + #[serde(rename = "deadline", skip_serializing_if = "Option::is_none")] + pub deadline: Option, + #[serde(rename = "cumulative_freeze_days", skip_serializing_if = "Option::is_none")] + pub cumulative_freeze_days: Option, + #[serde(rename = "is_activated", skip_serializing_if = "Option::is_none")] + pub is_activated: Option, + #[serde(rename = "activated_at", skip_serializing_if = "Option::is_none")] + pub activated_at: Option, + #[serde(rename = "allow_speed_up", skip_serializing_if = "Option::is_none")] + pub allow_speed_up: Option, + #[serde(rename = "user_id", skip_serializing_if = "Option::is_none")] + pub user_id: Option, + #[serde(rename = "last_milestone_achieved", skip_serializing_if = "Option::is_none")] + pub last_milestone_achieved: Option, + #[serde(rename = "last_milestone_validated_at", skip_serializing_if = "Option::is_none")] + pub last_milestone_validated_at: Option, + #[serde(rename = "total_added_days_before_activation", skip_serializing_if = "Option::is_none")] + pub total_added_days_before_activation: Option, + #[serde(rename = "freeze_days_before_activation", skip_serializing_if = "Option::is_none")] + pub freeze_days_before_activation: Option, + #[serde(rename = "gifted_days_before_activation", skip_serializing_if = "Option::is_none")] + pub gifted_days_before_activation: Option, + #[serde(rename = "total_added_days_after_activation", skip_serializing_if = "Option::is_none")] + pub total_added_days_after_activation: Option, + #[serde(rename = "freeze_days_after_activation", skip_serializing_if = "Option::is_none")] + pub freeze_days_after_activation: Option, + #[serde(rename = "gifted_days_after_activation", skip_serializing_if = "Option::is_none")] + pub gifted_days_after_activation: Option, + #[serde(rename = "system_days_after_activation", skip_serializing_if = "Option::is_none")] + pub system_days_after_activation: Option, + #[serde(rename = "deadline_days_delta_from_activation_date", skip_serializing_if = "Option::is_none")] + pub deadline_days_delta_from_activation_date: Option, + #[serde(rename = "pace_level", skip_serializing_if = "Option::is_none")] + pub pace_level: Option, + #[serde(rename = "milestone_level", skip_serializing_if = "Option::is_none")] + pub milestone_level: Option, + #[serde(rename = "current_milestone_deadline", skip_serializing_if = "Option::is_none")] + pub current_milestone_deadline: Option, + #[serde(rename = "current_milestone_max_deadline", skip_serializing_if = "Option::is_none")] + pub current_milestone_max_deadline: Option, + #[serde(rename = "common_core_max_deadline", skip_serializing_if = "Option::is_none")] + pub common_core_max_deadline: Option, + #[serde(rename = "intra_v2_blackhole_date", skip_serializing_if = "Option::is_none")] + pub intra_v2_blackhole_date: Option, + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, +} + +impl ResponseActivateUserUsersUserIdActivatePost { + pub fn new(id: i32, cursus_begin_date: String, matrix_version: i32, campus_id: i32) -> ResponseActivateUserUsersUserIdActivatePost { + ResponseActivateUserUsersUserIdActivatePost { + id, + login: None, + cursus_begin_date, + matrix_version, + campus_id, + pace: None, + milestone: None, + deadline: None, + cumulative_freeze_days: None, + is_activated: None, + activated_at: None, + allow_speed_up: None, + user_id: None, + last_milestone_achieved: None, + last_milestone_validated_at: None, + total_added_days_before_activation: None, + freeze_days_before_activation: None, + gifted_days_before_activation: None, + total_added_days_after_activation: None, + freeze_days_after_activation: None, + gifted_days_after_activation: None, + system_days_after_activation: None, + deadline_days_delta_from_activation_date: None, + pace_level: None, + milestone_level: None, + current_milestone_deadline: None, + current_milestone_max_deadline: None, + common_core_max_deadline: None, + intra_v2_blackhole_date: None, + error: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/speed_up_body.rs b/libft-api-v3-pace/src/models/speed_up_body.rs new file mode 100644 index 0000000..4166349 --- /dev/null +++ b/libft-api-v3-pace/src/models/speed_up_body.rs @@ -0,0 +1,27 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SpeedUpBody { + #[serde(rename = "should_speed_up")] + pub should_speed_up: bool, +} + +impl SpeedUpBody { + pub fn new(should_speed_up: bool) -> SpeedUpBody { + SpeedUpBody { + should_speed_up, + } + } +} + diff --git a/libft-api-v3-pace/src/models/update_campus.rs b/libft-api-v3-pace/src/models/update_campus.rs new file mode 100644 index 0000000..960fdb4 --- /dev/null +++ b/libft-api-v3-pace/src/models/update_campus.rs @@ -0,0 +1,36 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateCampus { + #[serde(rename = "is_activated", skip_serializing_if = "Option::is_none")] + pub is_activated: Option, + #[serde(rename = "is_kickoff_activated", skip_serializing_if = "Option::is_none")] + pub is_kickoff_activated: Option, + #[serde(rename = "webhook_uri", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub webhook_uri: Option>, + #[serde(rename = "webhook_secret", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub webhook_secret: Option>, +} + +impl UpdateCampus { + pub fn new() -> UpdateCampus { + UpdateCampus { + is_activated: None, + is_kickoff_activated: None, + webhook_uri: None, + webhook_secret: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/user.rs b/libft-api-v3-pace/src/models/user.rs new file mode 100644 index 0000000..f511574 --- /dev/null +++ b/libft-api-v3-pace/src/models/user.rs @@ -0,0 +1,60 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct User { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "login", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub login: Option>, + #[serde(rename = "cursus_begin_date")] + pub cursus_begin_date: String, + #[serde(rename = "matrix_version")] + pub matrix_version: i32, + #[serde(rename = "campus_id")] + pub campus_id: i32, + #[serde(rename = "pace", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pace: Option>, + #[serde(rename = "milestone", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub milestone: Option>, + #[serde(rename = "deadline", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub deadline: Option>, + #[serde(rename = "cumulative_freeze_days", skip_serializing_if = "Option::is_none")] + pub cumulative_freeze_days: Option, + #[serde(rename = "is_activated", skip_serializing_if = "Option::is_none")] + pub is_activated: Option, + #[serde(rename = "activated_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub activated_at: Option>, + #[serde(rename = "allow_speed_up", skip_serializing_if = "Option::is_none")] + pub allow_speed_up: Option, +} + +impl User { + pub fn new(id: i32, cursus_begin_date: String, matrix_version: i32, campus_id: i32) -> User { + User { + id, + login: None, + cursus_begin_date, + matrix_version, + campus_id, + pace: None, + milestone: None, + deadline: None, + cumulative_freeze_days: None, + is_activated: None, + activated_at: None, + allow_speed_up: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/user_activation_dry_run_output.rs b/libft-api-v3-pace/src/models/user_activation_dry_run_output.rs new file mode 100644 index 0000000..a337a1b --- /dev/null +++ b/libft-api-v3-pace/src/models/user_activation_dry_run_output.rs @@ -0,0 +1,83 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// UserActivationDryRunOutput : Sum up output of a user infos in a dry run activation. Fields are optional to be able to fill them one by one +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UserActivationDryRunOutput { + #[serde(rename = "user_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub user_id: Option>, + #[serde(rename = "cursus_begin_date", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub cursus_begin_date: Option>, + #[serde(rename = "last_milestone_achieved", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub last_milestone_achieved: Option>, + #[serde(rename = "last_milestone_validated_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub last_milestone_validated_at: Option>, + #[serde(rename = "total_added_days_before_activation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub total_added_days_before_activation: Option>, + #[serde(rename = "freeze_days_before_activation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub freeze_days_before_activation: Option>, + #[serde(rename = "gifted_days_before_activation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub gifted_days_before_activation: Option>, + #[serde(rename = "total_added_days_after_activation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub total_added_days_after_activation: Option>, + #[serde(rename = "freeze_days_after_activation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub freeze_days_after_activation: Option>, + #[serde(rename = "gifted_days_after_activation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub gifted_days_after_activation: Option>, + #[serde(rename = "system_days_after_activation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub system_days_after_activation: Option>, + #[serde(rename = "deadline_days_delta_from_activation_date", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub deadline_days_delta_from_activation_date: Option>, + #[serde(rename = "pace_level", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pace_level: Option>, + #[serde(rename = "milestone_level", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub milestone_level: Option>, + #[serde(rename = "current_milestone_deadline", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub current_milestone_deadline: Option>, + #[serde(rename = "current_milestone_max_deadline", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub current_milestone_max_deadline: Option>, + #[serde(rename = "common_core_max_deadline", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub common_core_max_deadline: Option>, + #[serde(rename = "intra_v2_blackhole_date", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub intra_v2_blackhole_date: Option>, + #[serde(rename = "error", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub error: Option>, +} + +impl UserActivationDryRunOutput { + /// Sum up output of a user infos in a dry run activation. Fields are optional to be able to fill them one by one + pub fn new() -> UserActivationDryRunOutput { + UserActivationDryRunOutput { + user_id: None, + cursus_begin_date: None, + last_milestone_achieved: None, + last_milestone_validated_at: None, + total_added_days_before_activation: None, + freeze_days_before_activation: None, + gifted_days_before_activation: None, + total_added_days_after_activation: None, + freeze_days_after_activation: None, + gifted_days_after_activation: None, + system_days_after_activation: None, + deadline_days_delta_from_activation_date: None, + pace_level: None, + milestone_level: None, + current_milestone_deadline: None, + current_milestone_max_deadline: None, + common_core_max_deadline: None, + intra_v2_blackhole_date: None, + error: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/user_activation_options.rs b/libft-api-v3-pace/src/models/user_activation_options.rs new file mode 100644 index 0000000..6b5a03b --- /dev/null +++ b/libft-api-v3-pace/src/models/user_activation_options.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UserActivationOptions { + #[serde(rename = "dry_run", skip_serializing_if = "Option::is_none")] + pub dry_run: Option, + #[serde(rename = "bypass_intra_v2_blackhole", skip_serializing_if = "Option::is_none")] + pub bypass_intra_v2_blackhole: Option, + #[serde(rename = "force_intra_v2_blackhole", skip_serializing_if = "Option::is_none")] + pub force_intra_v2_blackhole: Option, + #[serde(rename = "activation_date", skip_serializing_if = "Option::is_none")] + pub activation_date: Option, + #[serde(rename = "max_pace", skip_serializing_if = "Option::is_none")] + pub max_pace: Option, +} + +impl UserActivationOptions { + pub fn new() -> UserActivationOptions { + UserActivationOptions { + dry_run: None, + bypass_intra_v2_blackhole: None, + force_intra_v2_blackhole: None, + activation_date: None, + max_pace: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/user_milestone_validation.rs b/libft-api-v3-pace/src/models/user_milestone_validation.rs new file mode 100644 index 0000000..3bcd4e9 --- /dev/null +++ b/libft-api-v3-pace/src/models/user_milestone_validation.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UserMilestoneValidation { + #[serde(rename = "level")] + pub level: i32, + #[serde(rename = "deadline", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub deadline: Option>, + #[serde(rename = "validated_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub validated_at: Option>, + #[serde(rename = "user_id")] + pub user_id: i32, + #[serde(rename = "milestone_id")] + pub milestone_id: i32, +} + +impl UserMilestoneValidation { + pub fn new(level: i32, user_id: i32, milestone_id: i32) -> UserMilestoneValidation { + UserMilestoneValidation { + level, + deadline: None, + validated_at: None, + user_id, + milestone_id, + } + } +} + diff --git a/libft-api-v3-pace/src/models/user_profile.rs b/libft-api-v3-pace/src/models/user_profile.rs new file mode 100644 index 0000000..49dc9b8 --- /dev/null +++ b/libft-api-v3-pace/src/models/user_profile.rs @@ -0,0 +1,60 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UserProfile { + #[serde(rename = "is_activated")] + pub is_activated: bool, + #[serde(rename = "activated_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub activated_at: Option>, + #[serde(rename = "milestone", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub milestone: Option>, + #[serde(rename = "deadline", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub deadline: Option>, + #[serde(rename = "cursus_begin_date")] + pub cursus_begin_date: String, + #[serde(rename = "eta_end_of_cursus", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub eta_end_of_cursus: Option>, + #[serde(rename = "probationary_period")] + pub probationary_period: bool, + #[serde(rename = "milestones")] + pub milestones: Vec, + #[serde(rename = "is_campus_activated")] + pub is_campus_activated: bool, + #[serde(rename = "pace_speed_up", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pace_speed_up: Option>>, + #[serde(rename = "pace", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub pace: Option>, + #[serde(rename = "end_of_cursus_max_deadline", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub end_of_cursus_max_deadline: Option>, +} + +impl UserProfile { + pub fn new(is_activated: bool, cursus_begin_date: String, probationary_period: bool, milestones: Vec, is_campus_activated: bool) -> UserProfile { + UserProfile { + is_activated, + activated_at: None, + milestone: None, + deadline: None, + cursus_begin_date, + eta_end_of_cursus: None, + probationary_period, + milestones, + is_campus_activated, + pace_speed_up: None, + pace: None, + end_of_cursus_max_deadline: None, + } + } +} + diff --git a/libft-api-v3-pace/src/models/validation_error.rs b/libft-api-v3-pace/src/models/validation_error.rs new file mode 100644 index 0000000..8a62e4b --- /dev/null +++ b/libft-api-v3-pace/src/models/validation_error.rs @@ -0,0 +1,33 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ValidationError { + #[serde(rename = "loc")] + pub loc: Vec, + #[serde(rename = "msg")] + pub msg: String, + #[serde(rename = "type")] + pub r#type: String, +} + +impl ValidationError { + pub fn new(loc: Vec, msg: String, r#type: String) -> ValidationError { + ValidationError { + loc, + msg, + r#type, + } + } +} + diff --git a/libft-api-v3-pace/src/models/validation_error_loc_inner.rs b/libft-api-v3-pace/src/models/validation_error_loc_inner.rs new file mode 100644 index 0000000..8d92e5e --- /dev/null +++ b/libft-api-v3-pace/src/models/validation_error_loc_inner.rs @@ -0,0 +1,24 @@ +/* + * Intra v3 - Pace System + * + * Pace and milestone management + * + * The version of the OpenAPI document: 1.14.6 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ValidationErrorLocInner { +} + +impl ValidationErrorLocInner { + pub fn new() -> ValidationErrorLocInner { + ValidationErrorLocInner { + } + } +} + diff --git a/libft-api-v3/Cargo.toml b/libft-api-v3/Cargo.toml new file mode 100644 index 0000000..7dd5daf --- /dev/null +++ b/libft-api-v3/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "libft-api-v3-freeze" +version = "2.0.0" +authors = ["OpenAPI Generator team and contributors"] +description = "API for Freeze management for staff and students" +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2021" + +[dependencies] +serde = { version = "^1.0", features = ["derive"] } +serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] } +serde_json = "^1.0" +serde_repr = "^0.1" +url = "^2.5" +reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart"] } diff --git a/libft-api-v3/src/apis/campus_api.rs b/libft-api-v3/src/apis/campus_api.rs new file mode 100644 index 0000000..6adb9b6 --- /dev/null +++ b/libft-api-v3/src/apis/campus_api.rs @@ -0,0 +1,816 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use super::{configuration, ContentType, Error}; +use crate::{apis::ResponseContent, models}; +use reqwest; +use serde::{de::Error as _, Deserialize, Serialize}; + +/// struct for typed errors of method [`create_bonus_day_settings_bonus_days_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateBonusDaySettingsBonusDaysPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_campus_configuration_campus_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateCampusConfigurationCampusPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_campus_webhook_campus_campus_id_webhook_webhook_type_delete`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteCampusWebhookCampusCampusIdWebhookWebhookTypeDeleteError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_bonus_days_settings_bonus_days_bonus_day_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetBonusDaysSettingsBonusDaysBonusDayIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_campus_configuration_campus_campus_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCampusConfigurationCampusCampusIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_bonus_days_settings_bonus_days_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListBonusDaysSettingsBonusDaysGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_campus_custom_message_campus_custom_message_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListCampusCustomMessageCampusCustomMessageGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_campuses_configuration_campus_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListCampusesConfigurationCampusGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_enabled_campuses_campus_enabled_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListEnabledCampusesCampusEnabledGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_bonus_day_settings_bonus_days_bonus_day_id_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateBonusDaySettingsBonusDaysBonusDayIdPutError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_campus_configuration_campus_campus_id_patch`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateCampusConfigurationCampusCampusIdPatchError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_campus_pedago_mail_address_campus_campus_id_pedago_mail_address_patch`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateCampusPedagoMailAddressCampusCampusIdPedagoMailAddressPatchError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_campus_webhook_campus_campus_id_webhook_patch`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateCampusWebhookCampusCampusIdWebhookPatchError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// Create a `bonus_day` configuration +pub async fn create_bonus_day_settings_bonus_days_post( + configuration: &configuration::Configuration, + bonus_day_create: models::BonusDayCreate, +) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_bonus_day_create = bonus_day_create; + + let uri_str = format!("{}/bonus_days", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_bonus_day_create); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::BonusDay>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::BonusDay>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Create a new configation for a campus +pub async fn create_campus_configuration_campus_post( + configuration: &configuration::Configuration, + campus_create: models::CampusCreate, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_campus_create = campus_create; + + let uri_str = format!("{}/campus", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_campus_create); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Delete the webhook for a campus +pub async fn delete_campus_webhook_campus_campus_id_webhook_webhook_type_delete( + configuration: &configuration::Configuration, + campus_id: i32, + webhook_type: &str, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_campus_id = campus_id; + let p_webhook_type = webhook_type; + + let uri_str = format!( + "{}/campus/{campus_id}/webhook/{webhook_type}", + configuration.base_path, + campus_id = p_campus_id, + webhook_type = crate::apis::urlencode(p_webhook_type) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get `bonus_days` configuration for the given `bonus_day_id` +pub async fn get_bonus_days_settings_bonus_days_bonus_day_id_get( + configuration: &configuration::Configuration, + bonus_day_id: i32, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_bonus_day_id = bonus_day_id; + + let uri_str = format!( + "{}/bonus_days/{bonus_day_id}", + configuration.base_path, + bonus_day_id = p_bonus_day_id + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BonusDay`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BonusDay`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get one campus configuration on the given `campus_id` +pub async fn get_campus_configuration_campus_campus_id_get( + configuration: &configuration::Configuration, + campus_id: i32, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_campus_id = campus_id; + + let uri_str = format!( + "{}/campus/{campus_id}", + configuration.base_path, + campus_id = p_campus_id + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// List all `bonus_days` configurations for the current `campus_id` given by informations of the authenticated `User` +pub async fn list_bonus_days_settings_bonus_days_get( + configuration: &configuration::Configuration, + milestone_id: Option, + page: Option, + size: Option, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_milestone_id = milestone_id; + let p_page = page; + let p_size = size; + + let uri_str = format!("{}/bonus_days", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_milestone_id { + req_builder = req_builder.query(&[("milestone_id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageBonusDay`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageBonusDay`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// List all `custom message` from campuses configurations +pub async fn list_campus_custom_message_campus_custom_message_get( + configuration: &configuration::Configuration, +) -> Result< + Vec, + Error, +> { + let uri_str = format!("{}/campus/custom_message", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CampusCustomMessage>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CampusCustomMessage>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// List configurations for all campuses +pub async fn list_campuses_configuration_campus_get( + configuration: &configuration::Configuration, + page: Option, + size: Option, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_page = page; + let p_size = size; + + let uri_str = format!("{}/campus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageCampus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageCampus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// List all `enabled` campuses configurations +pub async fn list_enabled_campuses_campus_enabled_get( + configuration: &configuration::Configuration, +) -> Result, Error> { + let uri_str = format!("{}/campus/enabled", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Campus>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Campus>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Modify `bonus_day` configuration for the given `bonus_day_id` +pub async fn update_bonus_day_settings_bonus_days_bonus_day_id_put( + configuration: &configuration::Configuration, + bonus_day_id: i32, + bonus_day_update: models::BonusDayUpdate, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_bonus_day_id = bonus_day_id; + let p_bonus_day_update = bonus_day_update; + + let uri_str = format!( + "{}/bonus_days/{bonus_day_id}", + configuration.base_path, + bonus_day_id = p_bonus_day_id + ); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_bonus_day_update); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BonusDay`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BonusDay`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Modify configuation for a campus, based on the given `campus_id` +pub async fn update_campus_configuration_campus_campus_id_patch( + configuration: &configuration::Configuration, + campus_id: i32, + campus_update: models::CampusUpdate, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_campus_id = campus_id; + let p_campus_update = campus_update; + + let uri_str = format!( + "{}/campus/{campus_id}", + configuration.base_path, + campus_id = p_campus_id + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::PATCH, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_campus_update); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Update the pedago mail address for a campus +pub async fn update_campus_pedago_mail_address_campus_campus_id_pedago_mail_address_patch( + configuration: &configuration::Configuration, + campus_id: i32, + campus_mail_address_update: models::CampusMailAddressUpdate, +) -> Result< + models::Campus, + Error, +> { + // add a prefix to parameters to efficiently prevent name collisions + let p_campus_id = campus_id; + let p_campus_mail_address_update = campus_mail_address_update; + + let uri_str = format!( + "{}/campus/{campus_id}/pedago_mail_address", + configuration.base_path, + campus_id = p_campus_id + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::PATCH, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_campus_mail_address_update); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Update the webhook for a campus +pub async fn update_campus_webhook_campus_campus_id_webhook_patch( + configuration: &configuration::Configuration, + campus_id: i32, + campus_webhook_update: models::CampusWebhookUpdate, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_campus_id = campus_id; + let p_campus_webhook_update = campus_webhook_update; + + let uri_str = format!( + "{}/campus/{campus_id}/webhook", + configuration.base_path, + campus_id = p_campus_id + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::PATCH, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_campus_webhook_update); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Campus`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Campus`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} diff --git a/libft-api-v3/src/apis/configuration.rs b/libft-api-v3/src/apis/configuration.rs new file mode 100644 index 0000000..db48a44 --- /dev/null +++ b/libft-api-v3/src/apis/configuration.rs @@ -0,0 +1,48 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "/api/v2".to_owned(), + user_agent: Some("OpenAPI-Generator/2.0.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/libft-api-v3/src/apis/freeze_logs_api.rs b/libft-api-v3/src/apis/freeze_logs_api.rs new file mode 100644 index 0000000..7696c86 --- /dev/null +++ b/libft-api-v3/src/apis/freeze_logs_api.rs @@ -0,0 +1,187 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use super::{configuration, ContentType, Error}; +use crate::{apis::ResponseContent, models}; +use reqwest; +use serde::{de::Error as _, Deserialize, Serialize}; + +/// struct for typed errors of method [`get_freeze_log_freeze_logs_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetFreezeLogFreezeLogsIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_freeze_logs_freeze_logs_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListFreezeLogsFreezeLogsGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// Get a `freeze_log` for the given `id` +pub async fn get_freeze_log_freeze_logs_id_get( + configuration: &configuration::Configuration, + id: i32, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/freeze_logs/{id}", configuration.base_path, id = p_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FreezeLog`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FreezeLog`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get all `freeze logs` for the given filter parameters +pub async fn list_freeze_logs_freeze_logs_get( + configuration: &configuration::Configuration, + freeze_id: Option, + student_id: Option, + campus_id: Option, + status: Option<&str>, + begin_date: Option, + expected_end_date: Option, + created_at: Option, + effective_end_date: Option, + approved_at: Option, + triggered_by: Option<&str>, + ts: Option, + page: Option, + size: Option, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_freeze_id = freeze_id; + let p_student_id = student_id; + let p_campus_id = campus_id; + let p_status = status; + let p_begin_date = begin_date; + let p_expected_end_date = expected_end_date; + let p_created_at = created_at; + let p_effective_end_date = effective_end_date; + let p_approved_at = approved_at; + let p_triggered_by = triggered_by; + let p_ts = ts; + let p_page = page; + let p_size = size; + + let uri_str = format!("{}/freeze_logs", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_freeze_id { + req_builder = req_builder.query(&[("freeze_id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_student_id { + req_builder = req_builder.query(&[("student_id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_campus_id { + req_builder = req_builder.query(&[("campus_id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_begin_date { + req_builder = req_builder.query(&[("begin_date", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_expected_end_date { + req_builder = req_builder.query(&[("expected_end_date", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_created_at { + req_builder = req_builder.query(&[("created_at", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_effective_end_date { + req_builder = req_builder.query(&[("effective_end_date", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_approved_at { + req_builder = req_builder.query(&[("approved_at", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_triggered_by { + req_builder = req_builder.query(&[("triggered_by", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_ts { + req_builder = req_builder.query(&[("ts", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageFreezeLog`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageFreezeLog`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} diff --git a/libft-api-v3/src/apis/freezes_api.rs b/libft-api-v3/src/apis/freezes_api.rs new file mode 100644 index 0000000..1d6b295 --- /dev/null +++ b/libft-api-v3/src/apis/freezes_api.rs @@ -0,0 +1,812 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use super::{configuration, ContentType, Error}; +use crate::{apis::ResponseContent, models}; +use reqwest; +use serde::{de::Error as _, Deserialize, Serialize}; + +/// struct for typed errors of method [`approve_freeze_freezes_id_approve_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ApproveFreezeFreezesIdApprovePostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`cancel_freeze_freezes_id_cancel_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CancelFreezeFreezesIdCancelPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`count_pending_freezes_freezes_status_count_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CountPendingFreezesFreezesStatusCountGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_bulk_compensation_freezes_compensation_bulk_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateBulkCompensationFreezesCompensationBulkPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_user_freeze_freezes_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUserFreezeFreezesPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`force_approve_freeze_freezes_id_force_approve_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ForceApproveFreezeFreezesIdForceApprovePostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_freeze_freezes_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetFreezeFreezesIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_freeze_logs_by_freeze_id_freezes_id_freeze_logs_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetFreezeLogsByFreezeIdFreezesIdFreezeLogsGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`interrupt_freeze_freezes_id_interrupt_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum InterruptFreezeFreezesIdInterruptPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_freezes_freezes_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListFreezesFreezesGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`reject_freeze_freezes_id_reject_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RejectFreezeFreezesIdRejectPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`revert_freeze_freezes_id_revert_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RevertFreezeFreezesIdRevertPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// Approve a freeze for the given freeze `id` +pub async fn approve_freeze_freezes_id_approve_post( + configuration: &configuration::Configuration, + id: i32, + freeze_staff_action_description: models::FreezeStaffActionDescription, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + let p_freeze_staff_action_description = freeze_staff_action_description; + + let uri_str = format!( + "{}/freezes/{id}/approve", + configuration.base_path, + id = p_id + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_freeze_staff_action_description); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Freeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Freeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Cancel a compensation freeze for the given compensation freeze `id` only if it's in the future +pub async fn cancel_freeze_freezes_id_cancel_post( + configuration: &configuration::Configuration, + id: i32, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/freezes/{id}/cancel", configuration.base_path, id = p_id); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Freeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Freeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get selected status `user_freeze` count for the `campus` of the authenticated `User` +pub async fn count_pending_freezes_freezes_status_count_get( + configuration: &configuration::Configuration, + status: &str, +) -> Result< + std::collections::HashMap, + Error, +> { + // add a prefix to parameters to efficiently prevent name collisions + let p_status = status; + + let uri_str = format!( + "{}/freezes/{status}/count", + configuration.base_path, + status = crate::apis::urlencode(p_status) + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, i32>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, i32>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Create `compensation_day` for a list of `user_id` approved by the authenticated `User` +pub async fn create_bulk_compensation_freezes_compensation_bulk_post( + configuration: &configuration::Configuration, + freeze_bulk_create: models::FreezeBulkCreate, +) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_freeze_bulk_create = freeze_bulk_create; + + let uri_str = format!("{}/freezes/compensation/bulk", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_freeze_bulk_create); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Freeze>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Freeze>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Create a `user_freeze` approved by the authenticated `User` +pub async fn create_user_freeze_freezes_post( + configuration: &configuration::Configuration, + force: bool, + freeze_create: models::FreezeCreate, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_force = force; + let p_freeze_create = freeze_create; + + let uri_str = format!("{}/freezes", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + req_builder = req_builder.query(&[("force", &p_force.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_freeze_create); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Freeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Freeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Force approve a freeze for the given freeze `id` +pub async fn force_approve_freeze_freezes_id_force_approve_post( + configuration: &configuration::Configuration, + id: i32, + freeze_staff_action_description: models::FreezeStaffActionDescription, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + let p_freeze_staff_action_description = freeze_staff_action_description; + + let uri_str = format!( + "{}/freezes/{id}/force_approve", + configuration.base_path, + id = p_id + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_freeze_staff_action_description); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Freeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Freeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get `user_freeze` based on id +pub async fn get_freeze_freezes_id_get( + configuration: &configuration::Configuration, + id: i32, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/freezes/{id}", configuration.base_path, id = p_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Freeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Freeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get all freeze logs given freeze `id` +pub async fn get_freeze_logs_by_freeze_id_freezes_id_freeze_logs_get( + configuration: &configuration::Configuration, + id: i32, +) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!( + "{}/freezes/{id}/freeze_logs", + configuration.base_path, + id = p_id + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::FreezeLog>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::FreezeLog>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Interrupt a freeze for the given freeze id +pub async fn interrupt_freeze_freezes_id_interrupt_post( + configuration: &configuration::Configuration, + id: i32, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!( + "{}/freezes/{id}/interrupt", + configuration.base_path, + id = p_id + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Freeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Freeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get all `user_freeze` for the `campus` of the authenticated `User` +pub async fn list_freezes_freezes_get( + configuration: &configuration::Configuration, + user: Option<&str>, + status: Option>, + category: Option>, + campus: Option>, + page: Option, + size: Option, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user = user; + let p_status = status; + let p_category = category; + let p_campus = campus; + let p_page = page; + let p_size = size; + + let uri_str = format!("{}/freezes", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_user { + req_builder = req_builder.query(&[("user", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_status { + req_builder = match "multi" { + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("status".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "status", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), + }; + } + if let Some(ref param_value) = p_category { + req_builder = match "multi" { + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("category".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "category", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), + }; + } + if let Some(ref param_value) = p_campus { + req_builder = match "multi" { + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("campus".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "campus", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), + }; + } + if let Some(ref param_value) = p_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageFreeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageFreeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Reject a freeze for the given freeze `id` +pub async fn reject_freeze_freezes_id_reject_post( + configuration: &configuration::Configuration, + id: i32, + freeze_staff_action_description: models::FreezeStaffActionDescription, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + let p_freeze_staff_action_description = freeze_staff_action_description; + + let uri_str = format!("{}/freezes/{id}/reject", configuration.base_path, id = p_id); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_freeze_staff_action_description); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Freeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Freeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Revert a freeze for the given freeze id +pub async fn revert_freeze_freezes_id_revert_post( + configuration: &configuration::Configuration, + id: i32, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_id = id; + + let uri_str = format!("{}/freezes/{id}/revert", configuration.base_path, id = p_id); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Freeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Freeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} diff --git a/libft-api-v3/src/apis/me_api.rs b/libft-api-v3/src/apis/me_api.rs new file mode 100644 index 0000000..a3c599b --- /dev/null +++ b/libft-api-v3/src/apis/me_api.rs @@ -0,0 +1,412 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use super::{configuration, ContentType, Error}; +use crate::{apis::ResponseContent, models}; +use reqwest; +use serde::{de::Error as _, Deserialize, Serialize}; + +/// struct for typed errors of method [`cancel_current_user_freeze_users_me_freezes_freeze_id_cancel_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CancelCurrentUserFreezeUsersMeFreezesFreezeIdCancelPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_current_user_freeze_users_me_freezes_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateCurrentUserFreezeUsersMeFreezesPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_campus_custom_message_users_me_custom_message_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCampusCustomMessageUsersMeCustomMessageGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_current_user_information_users_me_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCurrentUserInformationUsersMeGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`interrupt_current_user_freeze_users_me_freezes_freeze_id_interrupt_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum InterruptCurrentUserFreezeUsersMeFreezesFreezeIdInterruptPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_current_user_freezes_users_me_freezes_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListCurrentUserFreezesUsersMeFreezesGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// Cancel a `Freeze` for the current authenticated `User` on the given `freeze_id` +pub async fn cancel_current_user_freeze_users_me_freezes_freeze_id_cancel_post( + configuration: &configuration::Configuration, + freeze_id: i32, +) -> Result< + models::FreezeStudent, + Error, +> { + // add a prefix to parameters to efficiently prevent name collisions + let p_freeze_id = freeze_id; + + let uri_str = format!( + "{}/users/me/freezes/{freeze_id}/cancel", + configuration.base_path, + freeze_id = p_freeze_id + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FreezeStudent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FreezeStudent`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Create a `Freeze` for the current authenticated `User` +pub async fn create_current_user_freeze_users_me_freezes_post( + configuration: &configuration::Configuration, + freeze_create: models::FreezeCreate, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_freeze_create = freeze_create; + + let uri_str = format!("{}/users/me/freezes", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_freeze_create); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FreezeStudent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FreezeStudent`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get the custom message for a campus +pub async fn get_campus_custom_message_users_me_custom_message_get( + configuration: &configuration::Configuration, +) -> Result> +{ + let uri_str = format!("{}/users/me/custom-message", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CampusCustomMessage`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CampusCustomMessage`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Retrieve the informations of the authenticated `User` +pub async fn get_current_user_information_users_me_get( + configuration: &configuration::Configuration, +) -> Result> { + let uri_str = format!("{}/users/me", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UserStudent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UserStudent`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Interrupt a `Freeze` for the current authenticated `User` on the given `freeze_id` +pub async fn interrupt_current_user_freeze_users_me_freezes_freeze_id_interrupt_post( + configuration: &configuration::Configuration, + freeze_id: i32, +) -> Result< + models::FreezeStudent, + Error, +> { + // add a prefix to parameters to efficiently prevent name collisions + let p_freeze_id = freeze_id; + + let uri_str = format!( + "{}/users/me/freezes/{freeze_id}/interrupt", + configuration.base_path, + freeze_id = p_freeze_id + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FreezeStudent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FreezeStudent`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// List the `Freezes` of the current authenticated `User` +pub async fn list_current_user_freezes_users_me_freezes_get( + configuration: &configuration::Configuration, + status: Option>, + category: Option>, + page: Option, + size: Option, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_status = status; + let p_category = category; + let p_page = page; + let p_size = size; + + let uri_str = format!("{}/users/me/freezes", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_status { + req_builder = match "multi" { + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("status".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "status", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), + }; + } + if let Some(ref param_value) = p_category { + req_builder = match "multi" { + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("category".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "category", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), + }; + } + if let Some(ref param_value) = p_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageFreezeStudent`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageFreezeStudent`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} diff --git a/libft-api-v3/src/apis/mod.rs b/libft-api-v3/src/apis/mod.rs new file mode 100644 index 0000000..9ebbc76 --- /dev/null +++ b/libft-api-v3/src/apis/mod.rs @@ -0,0 +1,122 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + } + serde_json::Value::String(s) => { + params.push((format!("{}[{}]", prefix, key), s.clone())) + } + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +/// Internal use only +/// A content type supported by this client. +#[allow(dead_code)] +enum ContentType { + Json, + Text, + Unsupported(String), +} + +impl From<&str> for ContentType { + fn from(content_type: &str) -> Self { + if content_type.starts_with("application") && content_type.contains("json") { + return Self::Json; + } else if content_type.starts_with("text/plain") { + return Self::Text; + } else { + return Self::Unsupported(content_type.to_string()); + } + } +} + +pub mod campus_api; +pub mod freeze_logs_api; +pub mod freezes_api; +pub mod me_api; +pub mod users_api; + +pub mod configuration; diff --git a/libft-api-v3/src/apis/users_api.rs b/libft-api-v3/src/apis/users_api.rs new file mode 100644 index 0000000..7e47735 --- /dev/null +++ b/libft-api-v3/src/apis/users_api.rs @@ -0,0 +1,510 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use super::{configuration, ContentType, Error}; +use crate::{apis::ResponseContent, models}; +use reqwest; +use serde::{de::Error as _, Deserialize, Serialize}; + +/// struct for typed errors of method [`activation_student_users_user_id_activate_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActivationStudentUsersUserIdActivatePostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_student_configuration_users_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateStudentConfigurationUsersPostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`deactivation_student_users_user_id_deactivate_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeactivationStudentUsersUserIdDeactivatePostError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_student_configuration_users_user_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetStudentConfigurationUsersUserIdGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_student_freezes_users_user_id_freezes_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetStudentFreezesUsersUserIdFreezesGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_users_users_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListUsersUsersGetError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_student_configuration_users_user_id_acquire_bonus_days_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateStudentConfigurationUsersUserIdAcquireBonusDaysPutError { + Status422(models::HttpValidationError), + UnknownValue(serde_json::Value), +} + +pub async fn activation_student_users_user_id_activate_post( + configuration: &configuration::Configuration, + user_id: &str, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user_id = user_id; + + let uri_str = format!( + "{}/users/{user_id}/activate", + configuration.base_path, + user_id = p_user_id.to_string() + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Create a `student data` +pub async fn create_student_configuration_users_post( + configuration: &configuration::Configuration, + user_create: models::UserCreate, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user_create = user_create; + + let uri_str = format!("{}/users", configuration.base_path); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_user_create); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +pub async fn deactivation_student_users_user_id_deactivate_post( + configuration: &configuration::Configuration, + user_id: &str, + reason: &str, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user_id = user_id; + let p_reason = reason; + + let uri_str = format!( + "{}/users/{user_id}/deactivate", + configuration.base_path, + user_id = p_user_id.to_string() + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); + + req_builder = req_builder.query(&[("reason", &p_reason.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Get a `student data` for the given `user_id` +pub async fn get_student_configuration_users_user_id_get( + configuration: &configuration::Configuration, + user_id: &str, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user_id = user_id; + + let uri_str = format!( + "{}/users/{user_id}", + configuration.base_path, + user_id = p_user_id.to_string() + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// List all past freezes for a given `user_id` +pub async fn get_student_freezes_users_user_id_freezes_get( + configuration: &configuration::Configuration, + user_id: &str, + page: Option, + size: Option, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user_id = user_id; + let p_page = page; + let p_size = size; + + let uri_str = format!( + "{}/users/{user_id}/freezes", + configuration.base_path, + user_id = p_user_id.to_string() + ); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageFreeze`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageFreeze`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// List all users +pub async fn list_users_users_get( + configuration: &configuration::Configuration, + page: Option, + size: Option, + user_id: Option, + login: Option<&str>, + campus_id: Option>, + is_freeze: Option, + is_activated: Option, + available_bonus_days: Option, + used_freeze_days: Option, + total_freeze_occurences: Option, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_page = page; + let p_size = size; + let p_user_id = user_id; + let p_login = login; + let p_campus_id = campus_id; + let p_is_freeze = is_freeze; + let p_is_activated = is_activated; + let p_available_bonus_days = available_bonus_days; + let p_used_freeze_days = used_freeze_days; + let p_total_freeze_occurences = total_freeze_occurences; + + let uri_str = format!("{}/users", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_size { + req_builder = req_builder.query(&[("size", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_user_id { + req_builder = req_builder.query(&[("user_id", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_login { + req_builder = req_builder.query(&[("login", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_campus_id { + req_builder = match "multi" { + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("campus_id".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "campus_id", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), + }; + } + if let Some(ref param_value) = p_is_freeze { + req_builder = req_builder.query(&[("is_freeze", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_is_activated { + req_builder = req_builder.query(&[("is_activated", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_available_bonus_days { + req_builder = req_builder.query(&[("available_bonus_days", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_used_freeze_days { + req_builder = req_builder.query(&[("used_freeze_days", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_total_freeze_occurences { + req_builder = req_builder.query(&[("total_freeze_occurences", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PageUser`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PageUser`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} + +/// Modify `user` data for the given `user` +pub async fn update_student_configuration_users_user_id_acquire_bonus_days_put( + configuration: &configuration::Configuration, + user_id: i32, + added_bonus_days: i32, +) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_user_id = user_id; + let p_added_bonus_days = added_bonus_days; + + let uri_str = format!( + "{}/users/{user_id}/acquire_bonus_days", + configuration.base_path, + user_id = p_user_id + ); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + req_builder = req_builder.query(&[("added_bonus_days", &p_added_bonus_days.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = + serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { + status, + content, + entity, + })) + } +} diff --git a/libft-api-v3/src/lib.rs b/libft-api-v3/src/lib.rs new file mode 100644 index 0000000..9556a0a --- /dev/null +++ b/libft-api-v3/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate reqwest; +extern crate serde; +extern crate serde_json; +extern crate serde_repr; +extern crate url; + +pub mod apis; +pub mod models; diff --git a/libft-api-v3/src/models/bonus_day.rs b/libft-api-v3/src/models/bonus_day.rs new file mode 100644 index 0000000..b1c64a1 --- /dev/null +++ b/libft-api-v3/src/models/bonus_day.rs @@ -0,0 +1,35 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BonusDay { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "campus_id")] + pub campus_id: i32, + #[serde(rename = "milestone_id")] + pub milestone_id: i32, + #[serde(rename = "granted_bonus_days")] + pub granted_bonus_days: i32, +} + +impl BonusDay { + pub fn new(id: i32, campus_id: i32, milestone_id: i32, granted_bonus_days: i32) -> BonusDay { + BonusDay { + id, + campus_id, + milestone_id, + granted_bonus_days, + } + } +} diff --git a/libft-api-v3/src/models/bonus_day_create.rs b/libft-api-v3/src/models/bonus_day_create.rs new file mode 100644 index 0000000..9df295d --- /dev/null +++ b/libft-api-v3/src/models/bonus_day_create.rs @@ -0,0 +1,32 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BonusDayCreate { + #[serde(rename = "campus_id")] + pub campus_id: i32, + #[serde(rename = "milestone_id")] + pub milestone_id: i32, + #[serde(rename = "granted_bonus_days")] + pub granted_bonus_days: i32, +} + +impl BonusDayCreate { + pub fn new(campus_id: i32, milestone_id: i32, granted_bonus_days: i32) -> BonusDayCreate { + BonusDayCreate { + campus_id, + milestone_id, + granted_bonus_days, + } + } +} diff --git a/libft-api-v3/src/models/bonus_day_update.rs b/libft-api-v3/src/models/bonus_day_update.rs new file mode 100644 index 0000000..86afa81 --- /dev/null +++ b/libft-api-v3/src/models/bonus_day_update.rs @@ -0,0 +1,32 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct BonusDayUpdate { + #[serde(rename = "milestone_id", deserialize_with = "Option::deserialize")] + pub milestone_id: Option, + #[serde( + rename = "granted_bonus_days", + deserialize_with = "Option::deserialize" + )] + pub granted_bonus_days: Option, +} + +impl BonusDayUpdate { + pub fn new(milestone_id: Option, granted_bonus_days: Option) -> BonusDayUpdate { + BonusDayUpdate { + milestone_id, + granted_bonus_days, + } + } +} diff --git a/libft-api-v3/src/models/campus.rs b/libft-api-v3/src/models/campus.rs new file mode 100644 index 0000000..d5576b3 --- /dev/null +++ b/libft-api-v3/src/models/campus.rs @@ -0,0 +1,114 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Campus { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "timezone")] + pub timezone: String, + #[serde(rename = "max_freeze_days_per_student")] + pub max_freeze_days_per_student: i32, + #[serde(rename = "freeze_min_duration")] + pub freeze_min_duration: i32, + #[serde(rename = "max_freeze_occurences_per_student")] + pub max_freeze_occurences_per_student: i32, + #[serde(rename = "default_bonus_days")] + pub default_bonus_days: i32, + #[serde(rename = "auto_approval_enabled")] + pub auto_approval_enabled: bool, + #[serde(rename = "auto_approval_max_freeze_duration")] + pub auto_approval_max_freeze_duration: i32, + #[serde(rename = "is_activated")] + pub is_activated: bool, + #[serde( + rename = "custom_message", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub custom_message: Option>, + #[serde( + rename = "pedago_mail_address", + skip_serializing_if = "Option::is_none" + )] + pub pedago_mail_address: Option>, + #[serde(rename = "bonus_days_settings")] + pub bonus_days_settings: Vec, + #[serde( + rename = "freeze_webhook_uri", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub freeze_webhook_uri: Option>, + #[serde( + rename = "freeze_webhook_secret", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub freeze_webhook_secret: Option>, + #[serde( + rename = "user_webhook_uri", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub user_webhook_uri: Option>, + #[serde( + rename = "user_webhook_secret", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub user_webhook_secret: Option>, +} + +impl Campus { + pub fn new( + id: i32, + name: String, + timezone: String, + max_freeze_days_per_student: i32, + freeze_min_duration: i32, + max_freeze_occurences_per_student: i32, + default_bonus_days: i32, + auto_approval_enabled: bool, + auto_approval_max_freeze_duration: i32, + is_activated: bool, + bonus_days_settings: Vec, + ) -> Campus { + Campus { + id, + name, + timezone, + max_freeze_days_per_student, + freeze_min_duration, + max_freeze_occurences_per_student, + default_bonus_days, + auto_approval_enabled, + auto_approval_max_freeze_duration, + is_activated, + custom_message: None, + pedago_mail_address: None, + bonus_days_settings, + freeze_webhook_uri: None, + freeze_webhook_secret: None, + user_webhook_uri: None, + user_webhook_secret: None, + } + } +} diff --git a/libft-api-v3/src/models/campus_create.rs b/libft-api-v3/src/models/campus_create.rs new file mode 100644 index 0000000..c243bc8 --- /dev/null +++ b/libft-api-v3/src/models/campus_create.rs @@ -0,0 +1,120 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CampusCreate { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "timezone")] + pub timezone: String, + #[serde( + rename = "max_freeze_days_per_student", + skip_serializing_if = "Option::is_none" + )] + pub max_freeze_days_per_student: Option, + #[serde( + rename = "freeze_min_duration", + skip_serializing_if = "Option::is_none" + )] + pub freeze_min_duration: Option, + #[serde( + rename = "max_freeze_occurences_per_student", + skip_serializing_if = "Option::is_none" + )] + pub max_freeze_occurences_per_student: Option, + #[serde(rename = "default_bonus_days", skip_serializing_if = "Option::is_none")] + pub default_bonus_days: Option, + #[serde( + rename = "auto_approval_enabled", + skip_serializing_if = "Option::is_none" + )] + pub auto_approval_enabled: Option, + #[serde( + rename = "auto_approval_max_freeze_duration", + skip_serializing_if = "Option::is_none" + )] + pub auto_approval_max_freeze_duration: Option, + #[serde(rename = "is_activated", skip_serializing_if = "Option::is_none")] + pub is_activated: Option, + #[serde( + rename = "custom_message", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub custom_message: Option>, + #[serde( + rename = "pedago_mail_address", + skip_serializing_if = "Option::is_none" + )] + pub pedago_mail_address: Option>, + #[serde( + rename = "bonus_days_settings", + skip_serializing_if = "Option::is_none" + )] + pub bonus_days_settings: Option>, + #[serde( + rename = "freeze_webhook_uri", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub freeze_webhook_uri: Option>, + #[serde( + rename = "freeze_webhook_secret", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub freeze_webhook_secret: Option>, + #[serde( + rename = "user_webhook_uri", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub user_webhook_uri: Option>, + #[serde( + rename = "user_webhook_secret", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub user_webhook_secret: Option>, +} + +impl CampusCreate { + pub fn new(id: i32, name: String, timezone: String) -> CampusCreate { + CampusCreate { + id, + name, + timezone, + max_freeze_days_per_student: None, + freeze_min_duration: None, + max_freeze_occurences_per_student: None, + default_bonus_days: None, + auto_approval_enabled: None, + auto_approval_max_freeze_duration: None, + is_activated: None, + custom_message: None, + pedago_mail_address: None, + bonus_days_settings: None, + freeze_webhook_uri: None, + freeze_webhook_secret: None, + user_webhook_uri: None, + user_webhook_secret: None, + } + } +} diff --git a/libft-api-v3/src/models/campus_custom_message.rs b/libft-api-v3/src/models/campus_custom_message.rs new file mode 100644 index 0000000..b4ab656 --- /dev/null +++ b/libft-api-v3/src/models/campus_custom_message.rs @@ -0,0 +1,29 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CampusCustomMessage { + #[serde(rename = "campus_id")] + pub campus_id: i32, + #[serde(rename = "custom_message")] + pub custom_message: String, +} + +impl CampusCustomMessage { + pub fn new(campus_id: i32, custom_message: String) -> CampusCustomMessage { + CampusCustomMessage { + campus_id, + custom_message, + } + } +} diff --git a/libft-api-v3/src/models/campus_mail_address_update.rs b/libft-api-v3/src/models/campus_mail_address_update.rs new file mode 100644 index 0000000..73e4045 --- /dev/null +++ b/libft-api-v3/src/models/campus_mail_address_update.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CampusMailAddressUpdate { + #[serde( + rename = "pedago_mail_address_to_add", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pedago_mail_address_to_add: Option>>, + #[serde( + rename = "pedago_mail_address_to_remove", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pedago_mail_address_to_remove: Option>>, +} + +impl CampusMailAddressUpdate { + pub fn new() -> CampusMailAddressUpdate { + CampusMailAddressUpdate { + pedago_mail_address_to_add: None, + pedago_mail_address_to_remove: None, + } + } +} diff --git a/libft-api-v3/src/models/campus_student.rs b/libft-api-v3/src/models/campus_student.rs new file mode 100644 index 0000000..43a97ef --- /dev/null +++ b/libft-api-v3/src/models/campus_student.rs @@ -0,0 +1,72 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CampusStudent { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "timezone")] + pub timezone: String, + #[serde(rename = "max_freeze_days_per_student")] + pub max_freeze_days_per_student: i32, + #[serde(rename = "freeze_min_duration")] + pub freeze_min_duration: i32, + #[serde(rename = "max_freeze_occurences_per_student")] + pub max_freeze_occurences_per_student: i32, + #[serde(rename = "default_bonus_days")] + pub default_bonus_days: i32, + #[serde(rename = "auto_approval_enabled")] + pub auto_approval_enabled: bool, + #[serde(rename = "auto_approval_max_freeze_duration")] + pub auto_approval_max_freeze_duration: i32, + #[serde(rename = "is_activated")] + pub is_activated: bool, + #[serde( + rename = "custom_message", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub custom_message: Option>, +} + +impl CampusStudent { + pub fn new( + id: i32, + name: String, + timezone: String, + max_freeze_days_per_student: i32, + freeze_min_duration: i32, + max_freeze_occurences_per_student: i32, + default_bonus_days: i32, + auto_approval_enabled: bool, + auto_approval_max_freeze_duration: i32, + is_activated: bool, + ) -> CampusStudent { + CampusStudent { + id, + name, + timezone, + max_freeze_days_per_student, + freeze_min_duration, + max_freeze_occurences_per_student, + default_bonus_days, + auto_approval_enabled, + auto_approval_max_freeze_duration, + is_activated, + custom_message: None, + } + } +} diff --git a/libft-api-v3/src/models/campus_update.rs b/libft-api-v3/src/models/campus_update.rs new file mode 100644 index 0000000..a696177 --- /dev/null +++ b/libft-api-v3/src/models/campus_update.rs @@ -0,0 +1,119 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CampusUpdate { + #[serde( + rename = "max_freeze_days_per_student", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub max_freeze_days_per_student: Option>, + #[serde( + rename = "freeze_min_duration", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub freeze_min_duration: Option>, + #[serde( + rename = "max_freeze_occurences_per_student", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub max_freeze_occurences_per_student: Option>, + #[serde( + rename = "default_bonus_days", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub default_bonus_days: Option>, + #[serde( + rename = "auto_approval_enabled", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub auto_approval_enabled: Option>, + #[serde( + rename = "auto_approval_max_freeze_duration", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub auto_approval_max_freeze_duration: Option>, + #[serde( + rename = "custom_message", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub custom_message: Option>, + #[serde( + rename = "freeze_webhook_uri", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub freeze_webhook_uri: Option>, + #[serde( + rename = "user_webhook_uri", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub user_webhook_uri: Option>, + #[serde( + rename = "freeze_webhook_secret", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub freeze_webhook_secret: Option>, + #[serde( + rename = "user_webhook_secret", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub user_webhook_secret: Option>, + #[serde( + rename = "pedago_mail_address", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pedago_mail_address: Option>>, +} + +impl CampusUpdate { + pub fn new() -> CampusUpdate { + CampusUpdate { + max_freeze_days_per_student: None, + freeze_min_duration: None, + max_freeze_occurences_per_student: None, + default_bonus_days: None, + auto_approval_enabled: None, + auto_approval_max_freeze_duration: None, + custom_message: None, + freeze_webhook_uri: None, + user_webhook_uri: None, + freeze_webhook_secret: None, + user_webhook_secret: None, + pedago_mail_address: None, + } + } +} diff --git a/libft-api-v3/src/models/campus_webhook_update.rs b/libft-api-v3/src/models/campus_webhook_update.rs new file mode 100644 index 0000000..fcc7dc3 --- /dev/null +++ b/libft-api-v3/src/models/campus_webhook_update.rs @@ -0,0 +1,39 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CampusWebhookUpdate { + #[serde( + rename = "freeze_webhook_uri", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub freeze_webhook_uri: Option>, + #[serde( + rename = "user_webhook_uri", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub user_webhook_uri: Option>, +} + +impl CampusWebhookUpdate { + pub fn new() -> CampusWebhookUpdate { + CampusWebhookUpdate { + freeze_webhook_uri: None, + user_webhook_uri: None, + } + } +} diff --git a/libft-api-v3/src/models/freeze.rs b/libft-api-v3/src/models/freeze.rs new file mode 100644 index 0000000..e68e2c1 --- /dev/null +++ b/libft-api-v3/src/models/freeze.rs @@ -0,0 +1,168 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Freeze { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "user")] + pub user: Box, + #[serde(rename = "reason", skip_serializing_if = "Option::is_none")] + pub reason: Option, + #[serde(rename = "category", skip_serializing_if = "Option::is_none")] + pub category: Option, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "is_free_freeze", skip_serializing_if = "Option::is_none")] + pub is_free_freeze: Option, + #[serde(rename = "begin_date")] + pub begin_date: String, + #[serde(rename = "expected_end_date")] + pub expected_end_date: String, + #[serde( + rename = "effective_end_date", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub effective_end_date: Option>, + #[serde( + rename = "student_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub student_description: Option>, + #[serde( + rename = "staff_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub staff_description: Option>, + #[serde( + rename = "approved_by", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub approved_by: Option>, + #[serde( + rename = "approved_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub approved_at: Option>, + #[serde( + rename = "created_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub created_at: Option>, + #[serde( + rename = "updated_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub updated_at: Option>, +} + +impl Freeze { + pub fn new( + id: i32, + user: models::User, + begin_date: String, + expected_end_date: String, + ) -> Freeze { + Freeze { + id, + user: Box::new(user), + reason: None, + category: None, + status: None, + is_free_freeze: None, + begin_date, + expected_end_date, + effective_end_date: None, + student_description: None, + staff_description: None, + approved_by: None, + approved_at: None, + created_at: None, + updated_at: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Reason { + #[serde(rename = "medical")] + Medical, + #[serde(rename = "personal")] + Personal, + #[serde(rename = "professional")] + Professional, + #[serde(rename = "other")] + Other, +} + +impl Default for Reason { + fn default() -> Reason { + Self::Medical + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Category { + #[serde(rename = "regular")] + Regular, + #[serde(rename = "bonus")] + Bonus, + #[serde(rename = "compensation")] + Compensation, +} + +impl Default for Category { + fn default() -> Category { + Self::Regular + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "approved")] + Approved, + #[serde(rename = "rejected")] + Rejected, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "cancelled")] + Cancelled, + #[serde(rename = "interrupted")] + Interrupted, + #[serde(rename = "ongoing")] + Ongoing, + #[serde(rename = "finished")] + Finished, + #[serde(rename = "reverted")] + Reverted, +} + +impl Default for Status { + fn default() -> Status { + Self::Approved + } +} diff --git a/libft-api-v3/src/models/freeze_bulk_create.rs b/libft-api-v3/src/models/freeze_bulk_create.rs new file mode 100644 index 0000000..671cf46 --- /dev/null +++ b/libft-api-v3/src/models/freeze_bulk_create.rs @@ -0,0 +1,95 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FreezeBulkCreate { + #[serde(rename = "user_ids")] + pub user_ids: Vec, + #[serde(rename = "begin_date")] + pub begin_date: String, + #[serde(rename = "expected_end_date")] + pub expected_end_date: String, + #[serde(rename = "reason", skip_serializing_if = "Option::is_none")] + pub reason: Option, + #[serde(rename = "category", skip_serializing_if = "Option::is_none")] + pub category: Option, + #[serde(rename = "is_free_freeze", skip_serializing_if = "Option::is_none")] + pub is_free_freeze: Option, + #[serde( + rename = "student_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub student_description: Option>, + #[serde( + rename = "staff_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub staff_description: Option>, +} + +impl FreezeBulkCreate { + pub fn new( + user_ids: Vec, + begin_date: String, + expected_end_date: String, + ) -> FreezeBulkCreate { + FreezeBulkCreate { + user_ids, + begin_date, + expected_end_date, + reason: None, + category: None, + is_free_freeze: None, + student_description: None, + staff_description: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Reason { + #[serde(rename = "medical")] + Medical, + #[serde(rename = "personal")] + Personal, + #[serde(rename = "professional")] + Professional, + #[serde(rename = "other")] + Other, +} + +impl Default for Reason { + fn default() -> Reason { + Self::Medical + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Category { + #[serde(rename = "regular")] + Regular, + #[serde(rename = "bonus")] + Bonus, + #[serde(rename = "compensation")] + Compensation, +} + +impl Default for Category { + fn default() -> Category { + Self::Regular + } +} diff --git a/libft-api-v3/src/models/freeze_create.rs b/libft-api-v3/src/models/freeze_create.rs new file mode 100644 index 0000000..2adff40 --- /dev/null +++ b/libft-api-v3/src/models/freeze_create.rs @@ -0,0 +1,126 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// FreezeCreate : Create Model used for single and bulk freeze create +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FreezeCreate { + #[serde(rename = "user_id")] + pub user_id: Box, + #[serde(rename = "begin_date")] + pub begin_date: String, + #[serde(rename = "expected_end_date")] + pub expected_end_date: String, + #[serde(rename = "reason", skip_serializing_if = "Option::is_none")] + pub reason: Option, + #[serde(rename = "category", skip_serializing_if = "Option::is_none")] + pub category: Option, + #[serde(rename = "is_free_freeze", skip_serializing_if = "Option::is_none")] + pub is_free_freeze: Option, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde( + rename = "student_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub student_description: Option>, + #[serde( + rename = "staff_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub staff_description: Option>, +} + +impl FreezeCreate { + /// Create Model used for single and bulk freeze create + pub fn new( + user_id: models::UserId, + begin_date: String, + expected_end_date: String, + ) -> FreezeCreate { + FreezeCreate { + user_id: Box::new(user_id), + begin_date, + expected_end_date, + reason: None, + category: None, + is_free_freeze: None, + status: None, + student_description: None, + staff_description: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Reason { + #[serde(rename = "medical")] + Medical, + #[serde(rename = "personal")] + Personal, + #[serde(rename = "professional")] + Professional, + #[serde(rename = "other")] + Other, +} + +impl Default for Reason { + fn default() -> Reason { + Self::Medical + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Category { + #[serde(rename = "regular")] + Regular, + #[serde(rename = "bonus")] + Bonus, + #[serde(rename = "compensation")] + Compensation, +} + +impl Default for Category { + fn default() -> Category { + Self::Regular + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "approved")] + Approved, + #[serde(rename = "rejected")] + Rejected, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "cancelled")] + Cancelled, + #[serde(rename = "interrupted")] + Interrupted, + #[serde(rename = "ongoing")] + Ongoing, + #[serde(rename = "finished")] + Finished, + #[serde(rename = "reverted")] + Reverted, +} + +impl Default for Status { + fn default() -> Status { + Self::Approved + } +} diff --git a/libft-api-v3/src/models/freeze_log.rs b/libft-api-v3/src/models/freeze_log.rs new file mode 100644 index 0000000..0272122 --- /dev/null +++ b/libft-api-v3/src/models/freeze_log.rs @@ -0,0 +1,110 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FreezeLog { + #[serde(rename = "freeze_id")] + pub freeze_id: i32, + #[serde(rename = "student_id")] + pub student_id: i32, + #[serde(rename = "campus_id")] + pub campus_id: i32, + #[serde(rename = "status")] + pub status: Status, + #[serde(rename = "begin_date")] + pub begin_date: String, + #[serde(rename = "expected_end_date")] + pub expected_end_date: String, + #[serde( + rename = "effective_end_date", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub effective_end_date: Option>, + #[serde( + rename = "created_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub created_at: Option>, + #[serde( + rename = "approved_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub approved_at: Option>, + #[serde( + rename = "triggered_by", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub triggered_by: Option>, + #[serde(rename = "ts")] + pub ts: String, +} + +impl FreezeLog { + pub fn new( + freeze_id: i32, + student_id: i32, + campus_id: i32, + status: Status, + begin_date: String, + expected_end_date: String, + ts: String, + ) -> FreezeLog { + FreezeLog { + freeze_id, + student_id, + campus_id, + status, + begin_date, + expected_end_date, + effective_end_date: None, + created_at: None, + approved_at: None, + triggered_by: None, + ts, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "approved")] + Approved, + #[serde(rename = "rejected")] + Rejected, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "cancelled")] + Cancelled, + #[serde(rename = "interrupted")] + Interrupted, + #[serde(rename = "ongoing")] + Ongoing, + #[serde(rename = "finished")] + Finished, + #[serde(rename = "reverted")] + Reverted, +} + +impl Default for Status { + fn default() -> Status { + Self::Approved + } +} diff --git a/libft-api-v3/src/models/freeze_staff_action_description.rs b/libft-api-v3/src/models/freeze_staff_action_description.rs new file mode 100644 index 0000000..4286cd3 --- /dev/null +++ b/libft-api-v3/src/models/freeze_staff_action_description.rs @@ -0,0 +1,31 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FreezeStaffActionDescription { + #[serde( + rename = "staff_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub staff_description: Option>, +} + +impl FreezeStaffActionDescription { + pub fn new() -> FreezeStaffActionDescription { + FreezeStaffActionDescription { + staff_description: None, + } + } +} diff --git a/libft-api-v3/src/models/freeze_student.rs b/libft-api-v3/src/models/freeze_student.rs new file mode 100644 index 0000000..0a997e7 --- /dev/null +++ b/libft-api-v3/src/models/freeze_student.rs @@ -0,0 +1,168 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FreezeStudent { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "user")] + pub user: Box, + #[serde(rename = "reason", skip_serializing_if = "Option::is_none")] + pub reason: Option, + #[serde(rename = "category", skip_serializing_if = "Option::is_none")] + pub category: Option, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "is_free_freeze", skip_serializing_if = "Option::is_none")] + pub is_free_freeze: Option, + #[serde(rename = "begin_date")] + pub begin_date: String, + #[serde(rename = "expected_end_date")] + pub expected_end_date: String, + #[serde( + rename = "effective_end_date", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub effective_end_date: Option>, + #[serde( + rename = "student_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub student_description: Option>, + #[serde( + rename = "staff_description", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub staff_description: Option>, + #[serde( + rename = "approved_by", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub approved_by: Option>, + #[serde( + rename = "approved_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub approved_at: Option>, + #[serde( + rename = "created_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub created_at: Option>, + #[serde( + rename = "updated_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub updated_at: Option>, +} + +impl FreezeStudent { + pub fn new( + id: i32, + user: models::UserStudent, + begin_date: String, + expected_end_date: String, + ) -> FreezeStudent { + FreezeStudent { + id, + user: Box::new(user), + reason: None, + category: None, + status: None, + is_free_freeze: None, + begin_date, + expected_end_date, + effective_end_date: None, + student_description: None, + staff_description: None, + approved_by: None, + approved_at: None, + created_at: None, + updated_at: None, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Reason { + #[serde(rename = "medical")] + Medical, + #[serde(rename = "personal")] + Personal, + #[serde(rename = "professional")] + Professional, + #[serde(rename = "other")] + Other, +} + +impl Default for Reason { + fn default() -> Reason { + Self::Medical + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Category { + #[serde(rename = "regular")] + Regular, + #[serde(rename = "bonus")] + Bonus, + #[serde(rename = "compensation")] + Compensation, +} + +impl Default for Category { + fn default() -> Category { + Self::Regular + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "approved")] + Approved, + #[serde(rename = "rejected")] + Rejected, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "cancelled")] + Cancelled, + #[serde(rename = "interrupted")] + Interrupted, + #[serde(rename = "ongoing")] + Ongoing, + #[serde(rename = "finished")] + Finished, + #[serde(rename = "reverted")] + Reverted, +} + +impl Default for Status { + fn default() -> Status { + Self::Approved + } +} diff --git a/libft-api-v3/src/models/http_validation_error.rs b/libft-api-v3/src/models/http_validation_error.rs new file mode 100644 index 0000000..b1a809c --- /dev/null +++ b/libft-api-v3/src/models/http_validation_error.rs @@ -0,0 +1,24 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct HttpValidationError { + #[serde(rename = "detail", skip_serializing_if = "Option::is_none")] + pub detail: Option>, +} + +impl HttpValidationError { + pub fn new() -> HttpValidationError { + HttpValidationError { detail: None } + } +} diff --git a/libft-api-v3/src/models/mod.rs b/libft-api-v3/src/models/mod.rs new file mode 100644 index 0000000..ec2dd17 --- /dev/null +++ b/libft-api-v3/src/models/mod.rs @@ -0,0 +1,58 @@ +pub mod bonus_day; +pub use self::bonus_day::BonusDay; +pub mod bonus_day_create; +pub use self::bonus_day_create::BonusDayCreate; +pub mod bonus_day_update; +pub use self::bonus_day_update::BonusDayUpdate; +pub mod campus; +pub use self::campus::Campus; +pub mod campus_create; +pub use self::campus_create::CampusCreate; +pub mod campus_custom_message; +pub use self::campus_custom_message::CampusCustomMessage; +pub mod campus_mail_address_update; +pub use self::campus_mail_address_update::CampusMailAddressUpdate; +pub mod campus_student; +pub use self::campus_student::CampusStudent; +pub mod campus_update; +pub use self::campus_update::CampusUpdate; +pub mod campus_webhook_update; +pub use self::campus_webhook_update::CampusWebhookUpdate; +pub mod freeze; +pub use self::freeze::Freeze; +pub mod freeze_bulk_create; +pub use self::freeze_bulk_create::FreezeBulkCreate; +pub mod freeze_create; +pub use self::freeze_create::FreezeCreate; +pub mod freeze_log; +pub use self::freeze_log::FreezeLog; +pub mod freeze_staff_action_description; +pub use self::freeze_staff_action_description::FreezeStaffActionDescription; +pub mod freeze_student; +pub use self::freeze_student::FreezeStudent; +pub mod http_validation_error; +pub use self::http_validation_error::HttpValidationError; +pub mod page_bonus_day_; +pub use self::page_bonus_day_::PageBonusDay; +pub mod page_campus_; +pub use self::page_campus_::PageCampus; +pub mod page_freeze_; +pub use self::page_freeze_::PageFreeze; +pub mod page_freeze_log_; +pub use self::page_freeze_log_::PageFreezeLog; +pub mod page_freeze_student_; +pub use self::page_freeze_student_::PageFreezeStudent; +pub mod page_user_; +pub use self::page_user_::PageUser; +pub mod user; +pub use self::user::User; +pub mod user_create; +pub use self::user_create::UserCreate; +pub mod user_id; +pub use self::user_id::UserId; +pub mod user_student; +pub use self::user_student::UserStudent; +pub mod validation_error; +pub use self::validation_error::ValidationError; +pub mod validation_error_loc_inner; +pub use self::validation_error_loc_inner::ValidationErrorLocInner; diff --git a/libft-api-v3/src/models/page_bonus_day_.rs b/libft-api-v3/src/models/page_bonus_day_.rs new file mode 100644 index 0000000..f5d7848 --- /dev/null +++ b/libft-api-v3/src/models/page_bonus_day_.rs @@ -0,0 +1,43 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageBonusDay { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total")] + pub total: i32, + #[serde(rename = "page")] + pub page: i32, + #[serde(rename = "size")] + pub size: i32, + #[serde( + rename = "pages", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pages: Option>, +} + +impl PageBonusDay { + pub fn new(items: Vec, total: i32, page: i32, size: i32) -> PageBonusDay { + PageBonusDay { + items, + total, + page, + size, + pages: None, + } + } +} diff --git a/libft-api-v3/src/models/page_campus_.rs b/libft-api-v3/src/models/page_campus_.rs new file mode 100644 index 0000000..780a745 --- /dev/null +++ b/libft-api-v3/src/models/page_campus_.rs @@ -0,0 +1,43 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageCampus { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total")] + pub total: i32, + #[serde(rename = "page")] + pub page: i32, + #[serde(rename = "size")] + pub size: i32, + #[serde( + rename = "pages", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pages: Option>, +} + +impl PageCampus { + pub fn new(items: Vec, total: i32, page: i32, size: i32) -> PageCampus { + PageCampus { + items, + total, + page, + size, + pages: None, + } + } +} diff --git a/libft-api-v3/src/models/page_freeze_.rs b/libft-api-v3/src/models/page_freeze_.rs new file mode 100644 index 0000000..a8bdde8 --- /dev/null +++ b/libft-api-v3/src/models/page_freeze_.rs @@ -0,0 +1,43 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageFreeze { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total")] + pub total: i32, + #[serde(rename = "page")] + pub page: i32, + #[serde(rename = "size")] + pub size: i32, + #[serde( + rename = "pages", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pages: Option>, +} + +impl PageFreeze { + pub fn new(items: Vec, total: i32, page: i32, size: i32) -> PageFreeze { + PageFreeze { + items, + total, + page, + size, + pages: None, + } + } +} diff --git a/libft-api-v3/src/models/page_freeze_log_.rs b/libft-api-v3/src/models/page_freeze_log_.rs new file mode 100644 index 0000000..2cd5112 --- /dev/null +++ b/libft-api-v3/src/models/page_freeze_log_.rs @@ -0,0 +1,43 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageFreezeLog { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total")] + pub total: i32, + #[serde(rename = "page")] + pub page: i32, + #[serde(rename = "size")] + pub size: i32, + #[serde( + rename = "pages", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pages: Option>, +} + +impl PageFreezeLog { + pub fn new(items: Vec, total: i32, page: i32, size: i32) -> PageFreezeLog { + PageFreezeLog { + items, + total, + page, + size, + pages: None, + } + } +} diff --git a/libft-api-v3/src/models/page_freeze_student_.rs b/libft-api-v3/src/models/page_freeze_student_.rs new file mode 100644 index 0000000..9c4d259 --- /dev/null +++ b/libft-api-v3/src/models/page_freeze_student_.rs @@ -0,0 +1,48 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageFreezeStudent { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total")] + pub total: i32, + #[serde(rename = "page")] + pub page: i32, + #[serde(rename = "size")] + pub size: i32, + #[serde( + rename = "pages", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pages: Option>, +} + +impl PageFreezeStudent { + pub fn new( + items: Vec, + total: i32, + page: i32, + size: i32, + ) -> PageFreezeStudent { + PageFreezeStudent { + items, + total, + page, + size, + pages: None, + } + } +} diff --git a/libft-api-v3/src/models/page_user_.rs b/libft-api-v3/src/models/page_user_.rs new file mode 100644 index 0000000..6fb00cd --- /dev/null +++ b/libft-api-v3/src/models/page_user_.rs @@ -0,0 +1,43 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PageUser { + #[serde(rename = "items")] + pub items: Vec, + #[serde(rename = "total")] + pub total: i32, + #[serde(rename = "page")] + pub page: i32, + #[serde(rename = "size")] + pub size: i32, + #[serde( + rename = "pages", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub pages: Option>, +} + +impl PageUser { + pub fn new(items: Vec, total: i32, page: i32, size: i32) -> PageUser { + PageUser { + items, + total, + page, + size, + pages: None, + } + } +} diff --git a/libft-api-v3/src/models/user.rs b/libft-api-v3/src/models/user.rs new file mode 100644 index 0000000..934129c --- /dev/null +++ b/libft-api-v3/src/models/user.rs @@ -0,0 +1,83 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct User { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "campus")] + pub campus: Box, + #[serde(rename = "login")] + pub login: String, + #[serde(rename = "available_bonus_days")] + pub available_bonus_days: i32, + #[serde( + rename = "mail_address", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub mail_address: Option>, + #[serde(rename = "used_freeze_days")] + pub used_freeze_days: i32, + #[serde(rename = "total_freeze_occurences")] + pub total_freeze_occurences: i32, + #[serde(rename = "is_freeze")] + pub is_freeze: bool, + #[serde(rename = "is_activated")] + pub is_activated: bool, + #[serde( + rename = "cursus_begin_date", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub cursus_begin_date: Option>, + #[serde( + rename = "anonymized_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub anonymized_at: Option>, + #[serde(rename = "is_locked", skip_serializing_if = "Option::is_none")] + pub is_locked: Option, +} + +impl User { + pub fn new( + id: i32, + campus: models::Campus, + login: String, + available_bonus_days: i32, + used_freeze_days: i32, + total_freeze_occurences: i32, + is_freeze: bool, + is_activated: bool, + ) -> User { + User { + id, + campus: Box::new(campus), + login, + available_bonus_days, + mail_address: None, + used_freeze_days, + total_freeze_occurences, + is_freeze, + is_activated, + cursus_begin_date: None, + anonymized_at: None, + is_locked: None, + } + } +} diff --git a/libft-api-v3/src/models/user_create.rs b/libft-api-v3/src/models/user_create.rs new file mode 100644 index 0000000..6a79303 --- /dev/null +++ b/libft-api-v3/src/models/user_create.rs @@ -0,0 +1,69 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UserCreate { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "campus_id")] + pub campus_id: i32, + #[serde(rename = "login")] + pub login: String, + #[serde( + rename = "mail_address", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub mail_address: Option>, + #[serde( + rename = "available_bonus_days", + skip_serializing_if = "Option::is_none" + )] + pub available_bonus_days: Option, + #[serde(rename = "used_freeze_days", skip_serializing_if = "Option::is_none")] + pub used_freeze_days: Option, + #[serde( + rename = "total_freeze_occurences", + skip_serializing_if = "Option::is_none" + )] + pub total_freeze_occurences: Option, + #[serde(rename = "is_freeze", skip_serializing_if = "Option::is_none")] + pub is_freeze: Option, + #[serde(rename = "is_activated", skip_serializing_if = "Option::is_none")] + pub is_activated: Option, + #[serde( + rename = "cursus_begin_date", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub cursus_begin_date: Option>, +} + +impl UserCreate { + pub fn new(id: i32, campus_id: i32, login: String) -> UserCreate { + UserCreate { + id, + campus_id, + login, + mail_address: None, + available_bonus_days: None, + used_freeze_days: None, + total_freeze_occurences: None, + is_freeze: None, + is_activated: None, + cursus_begin_date: None, + } + } +} diff --git a/libft-api-v3/src/models/user_id.rs b/libft-api-v3/src/models/user_id.rs new file mode 100644 index 0000000..1958012 --- /dev/null +++ b/libft-api-v3/src/models/user_id.rs @@ -0,0 +1,21 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UserId {} + +impl UserId { + pub fn new() -> UserId { + UserId {} + } +} diff --git a/libft-api-v3/src/models/user_student.rs b/libft-api-v3/src/models/user_student.rs new file mode 100644 index 0000000..666c94b --- /dev/null +++ b/libft-api-v3/src/models/user_student.rs @@ -0,0 +1,80 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UserStudent { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "campus")] + pub campus: Box, + #[serde(rename = "login")] + pub login: String, + #[serde(rename = "available_bonus_days")] + pub available_bonus_days: i32, + #[serde( + rename = "mail_address", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub mail_address: Option>, + #[serde(rename = "used_freeze_days")] + pub used_freeze_days: i32, + #[serde(rename = "total_freeze_occurences")] + pub total_freeze_occurences: i32, + #[serde(rename = "is_freeze")] + pub is_freeze: bool, + #[serde(rename = "is_activated")] + pub is_activated: bool, + #[serde( + rename = "cursus_begin_date", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub cursus_begin_date: Option>, + #[serde( + rename = "anonymized_at", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub anonymized_at: Option>, +} + +impl UserStudent { + pub fn new( + id: i32, + campus: models::CampusStudent, + login: String, + available_bonus_days: i32, + used_freeze_days: i32, + total_freeze_occurences: i32, + is_freeze: bool, + is_activated: bool, + ) -> UserStudent { + UserStudent { + id, + campus: Box::new(campus), + login, + available_bonus_days, + mail_address: None, + used_freeze_days, + total_freeze_occurences, + is_freeze, + is_activated, + cursus_begin_date: None, + anonymized_at: None, + } + } +} diff --git a/libft-api-v3/src/models/validation_error.rs b/libft-api-v3/src/models/validation_error.rs new file mode 100644 index 0000000..e52cb28 --- /dev/null +++ b/libft-api-v3/src/models/validation_error.rs @@ -0,0 +1,32 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ValidationError { + #[serde(rename = "loc")] + pub loc: Vec, + #[serde(rename = "msg")] + pub msg: String, + #[serde(rename = "type")] + pub r#type: String, +} + +impl ValidationError { + pub fn new( + loc: Vec, + msg: String, + r#type: String, + ) -> ValidationError { + ValidationError { loc, msg, r#type } + } +} diff --git a/libft-api-v3/src/models/validation_error_loc_inner.rs b/libft-api-v3/src/models/validation_error_loc_inner.rs new file mode 100644 index 0000000..f6df3fd --- /dev/null +++ b/libft-api-v3/src/models/validation_error_loc_inner.rs @@ -0,0 +1,21 @@ +/* + * Intra v3 - Freeze + * + * API for Freeze management for staff and students + * + * The version of the OpenAPI document: 2.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ValidationErrorLocInner {} + +impl ValidationErrorLocInner { + pub fn new() -> ValidationErrorLocInner { + ValidationErrorLocInner {} + } +} diff --git a/libft-api/bin/campus_users.rs b/libft-api/bin/campus_users.rs new file mode 100644 index 0000000..f6faf32 --- /dev/null +++ b/libft-api/bin/campus_users.rs @@ -0,0 +1,207 @@ +use std::{io::Write, ops::ControlFlow, sync::Arc, time::Duration}; + +use chrono::Utc; +use libft_api::{campus_id::GYEONGSAN, prelude::*}; +use rvstruct::ValueStruct; +use tokio::{sync::Semaphore, task::JoinSet, time::sleep}; +use tracing::info; + +#[tokio::main] +async fn main() -> Result<(), Box> { + tracing_subscriber::fmt::init(); + let thread_num = 4; + let permit = Arc::new(Semaphore::new(thread_num)); + // let ids = [ + // 212531, 212530, 212529, 212528, 212527, 212526, 212525, 212524, 212523, 212522, 212521, + // 212520, 212519, 212518, 212517, 212516, 212515, 212514, 212513, 212512, 212511, 212510, + // 212509, 212508, 212507, 212506, 212505, 212504, 212503, 212502, 212501, 212500, 212499, + // 212498, 212497, 212496, 212495, 212494, 212493, 212492, 212491, 212490, 212489, 212488, + // 212487, 212486, 212485, 212484, 212483, 212482, 212481, 212480, 212479, 212478, 212477, + // 212476, 212475, 212474, 212473, 212472, 212471, 212470, 212469, 212468, 212467, 212466, + // 212465, 212464, 212463, 212462, 212461, 212460, 212459, 212458, 212457, 212456, 212455, + // 212454, 212453, 212452, 212638, 212637, 212629, 212628, 212627, 212626, 212625, 212624, + // 212623, 212622, 212621, 212620, 212619, 212618, 212617, 212616, 212615, 212614, 212613, + // 212612, 212611, 212610, 212609, 212608, 212607, 212606, 212605, 212604, 212603, 212602, + // 212601, 212600, 212599, 212598, 212597, 212596, 212595, 212594, 212593, 212592, 212591, + // 212590, 212589, 212588, 212587, 212586, 212585, 212584, 212583, 212582, 212581, 212580, + // 212579, 212578, 212577, 212576, 212575, 212574, 212573, 212572, 212571, 212570, 212569, + // 212568, 212567, 212566, 212565, 212564, 212563, 212562, 212561, 212560, 212559, 212558, + // 212557, 212556, 212555, 212554, 212553, 212552, 212551, 212550, 212549, 212548, 212547, + // 212546, 212545, 212544, 212543, 212542, 212541, 212540, 212539, 212538, 212537, 212536, + // 212535, 212534, 212533, 212532, + // ] + // .map(FtUserId::new); + + let mut handles = JoinSet::new(); + + for mut page in 1..=thread_num { + let permit = Arc::clone(&permit); + handles.spawn(async move { + let _permit = permit.acquire().await.unwrap(); + let mut result = Vec::new(); + loop { + if let ControlFlow::Break(()) = get_users(&mut result, thread_num, &mut page).await + { + break result + .into_iter() + .filter_map(|user| user.id) + .collect::>(); + } + } + }); + } + + let mut ids = Vec::new(); + while let Some(Ok(res)) = handles.join_next().await { + ids.extend(res); + } + info!("{:#?}", ids); + + let mut handles = JoinSet::new(); + + let mut result = Vec::new(); + for id in ids { + let permit = Arc::clone(&permit); + handles.spawn(async move { + let _permit = permit.acquire().await.unwrap(); + let mut result = Vec::new(); + let mut page = 1; + loop { + if let ControlFlow::Break(()) = + get_projects_users(&mut result, &id, &mut page).await + { + break result; + } + } + }); + } + + while let Some(Ok(res)) = handles.join_next().await { + result.extend(res); + info!("{}", result.len()); + } + + let file_path = format!( + "/Users/hdoo/works/gsia/codes/libft-api/libft-api/bin/piscine/third_cohort/first_round/progress_{}.csv", + Utc::now().format("%Y-%m-%d_%H-%M-%S") + ); + + let mut file = std::fs::File::create(&file_path).expect("Failed to create output file"); + + file.write_all( + "user_id,login,project_name,marked_at,created_at,final_mark,updated_at\n".as_bytes(), + )?; + + for projects_user in result { + let (id, login) = { + let user = projects_user + .user + .expect("projects_users always have user."); + ( + user.id.map(|id| id.to_string()).unwrap_or("".to_string()), + user.login + .map(|id| id.to_string()) + .unwrap_or("".to_string()), + ) + }; + writeln!( + file, + "{},{},{},{:?},{},{:?},{}", + id, + login, + projects_user.project.name, + projects_user.marked_at, + projects_user.created_at.value(), + projects_user.final_mark, + Utc::now() + ) + .expect("Failed to write record"); + } + + println!("Output written to: {}", file_path); + Ok(()) +} + +async fn get_projects_users( + result: &mut Vec, + id: &FtUserId, + page: &mut i32, +) -> ControlFlow<()> { + let token = FtApiToken::try_get(AuthInfo::build_from_env().unwrap()) + .await + .unwrap(); + let client = FtClient::new(FtClientReqwestConnector::new()); + let session = Arc::new(client.open_session(&token)); + let res = session + .users_id_projects_users( + FtApiUsersIdProjectsUsersRequest::new(*id) + .with_per_page(100) + .with_page(*page as u16), + ) + .await; + match res { + Ok(res) => { + if res.projects_users.is_empty() { + return ControlFlow::Break(()); + } + result.extend(res.projects_users); + *page += 1; + } + Err(FtClientError::RateLimitError(_)) => sleep(Duration::new(1, 42)).await, + Err(e) => { + eprintln!("other error: {e}"); + return ControlFlow::Break(()); + } + } + ControlFlow::Continue(()) +} + +async fn get_users( + result: &mut Vec, + thread_num: usize, + page: &mut usize, +) -> ControlFlow<()> { + let token = FtApiToken::try_get(AuthInfo::build_from_env().unwrap()) + .await + .unwrap(); + let client = FtClient::new(FtClientReqwestConnector::new()); + let session = Arc::new(client.open_session(&token)); + let res = session + .users( + FtApiUsersRequest::new() + .with_per_page(100) + .with_page(*page as u16) + .with_range(vec![FtRangeOption::new( + FtRangeField::CreatedAt, + vec!["2025-1-1".to_string(), "2025-2-1".to_string()], + )]) + .with_filter(vec![ + FtFilterOption::new( + FtFilterField::PrimaryCampusId, + vec![GYEONGSAN.to_string()], + ), + FtFilterOption::new(FtFilterField::Kind, vec!["student".to_string()]), + ]), + ) + .await; + + match res { + Ok(res) => { + if res.users.is_empty() { + return ControlFlow::Break(()); + } + res.users + .iter() + .for_each(|user| println!("{:?}, {:?}", user.id, user.login)); + result.extend(res.users); + info!("{}", result.len()); + *page += thread_num; + } + Err(FtClientError::RateLimitError(_)) => sleep(Duration::new(1, 42)).await, + Err(e) => { + eprintln!("other error: {e}"); + return ControlFlow::Break(()); + } + } + ControlFlow::Continue(()) +} diff --git a/libft-api/bin/evaluation.rs b/libft-api/bin/evaluation.rs new file mode 100644 index 0000000..a4cbd08 --- /dev/null +++ b/libft-api/bin/evaluation.rs @@ -0,0 +1,268 @@ +use std::{collections::HashMap, io::Write, ops::ControlFlow, sync::Arc, time::Duration}; + +use chrono::Utc; +use libft_api::{campus_id::*, prelude::*, FT_CURSUS_ID, FT_PISCINE_CURSUS_ID}; +use rvstruct::ValueStruct; +use tokio::{sync::Semaphore, task::JoinSet, time::sleep}; +use tracing::info; + +#[tokio::main] +async fn main() -> Result<(), Box> { + tracing_subscriber::fmt::init(); + let thread_num = 8; + let permit = Arc::new(Semaphore::new(thread_num)); + + let ids = [ + // use same users + ] + .map(FtUserId::new); + let mut handles = JoinSet::new(); + + for id in ids { + let permit = Arc::clone(&permit); + handles.spawn(async move { + let _permit = permit.acquire().await.unwrap(); + let mut result = HashMap::new(); + let mut page = 1; + loop { + if let ControlFlow::Break(()) = + get_evaluation_historics(&mut result, &id, &mut page).await + { + break result; + } + } + }); + } + + let mut historics_of_students = Vec::new(); + while let Some(Ok(res)) = handles.join_next().await { + historics_of_students.extend(res); + info!("{}", historics_of_students.len()); + } + + let file_path = format!( + "./evaluation_historics_{}.csv", + Utc::now().format("%Y-%m-%d_%H-%M-%S") + ); + + let mut file = std::fs::File::create(&file_path).expect("Failed to create output file"); + + file.write_all( + "id, created_at, reason, scale_team_id, sum, total, updated_at, intra_id\n".as_bytes(), + )?; + + for (intra_id, historics) in historics_of_students { + for history in historics { + writeln!( + file, + "{},{},{},{},{},{},{},{}", + history.id, + history.created_at.0.to_utc(), + history.reason, + history + .scale_team_id + .map(|team| team.value().to_string()) + .unwrap_or("".to_string()), + history.sum, + history.total, + history.updated_at.0.to_utc(), + intra_id + ) + .expect("Failed to write record"); + } + } + + // let mut handles = JoinSet::new(); + // + // let mut scale_teams = Vec::new(); + // for mut page in 1..=thread_num { + // let permit = Arc::clone(&permit); + // handles.spawn(async move { + // let _permit = permit.acquire().await.unwrap(); + // let mut result = Vec::new(); + // loop { + // if let ControlFlow::Break(()) = + // get_scale_teams(&mut result, &mut page, thread_num).await + // { + // break result; + // } + // } + // }); + // } + // + // while let Some(Ok(res)) = handles.join_next().await { + // scale_teams.extend(res); + // info!("{}", scale_teams.len()); + // } + // + // let file_path = format!( + // "./scale_teams_{}.csv", + // Utc::now().format("%Y-%m-%d_%H-%M-%S") + // ); + // + // let mut file = std::fs::File::create(&file_path).expect("Failed to create output file"); + // + // file.write_all("project_idㅣscale_team_idㅣcreated_atㅣupdated_atㅣfinal_markㅣbegin_atㅣcorrectorㅣcorrectedsㅣfilled_atㅣtruantㅣteam.userㅣcommentㅣfeedback\n".as_bytes())?; + // + // for scale_team in scale_teams { + // let corrector = match scale_team.corrector { + // FtCorrector::User(ft_user) => { + // ft_user.login.map(|login| login.0).unwrap_or("".to_string()) + // } + // FtCorrector::String(s) => s, + // }; + // let correcteds = match scale_team.correcteds { + // FtCorrecteds::String(s) => s, + // FtCorrecteds::Vec(vec) => vec + // .into_iter() + // .map(|user| user.login.map(|l| l.0).unwrap_or("".to_string())) + // .collect::>() + // .join(","), + // }; + // let begin_at = match scale_team.begin_at { + // Some(date) => date.0.to_utc().to_string(), + // None => "".to_string(), + // }; + // let filled_at = match scale_team.filled_at { + // Some(date) => date.0.to_utc().to_string(), + // None => "".to_string(), + // }; + // + // let truant = match scale_team.truant { + // Some(user) => user + // .login + // .map(|l| l.0.to_string()) + // .unwrap_or("".to_string()), + // None => "".to_string(), + // }; + // let (team_uesr, project_id) = match scale_team.team { + // Some(team) => { + // let user = team + // .users + // .map(|users| { + // users + // .into_iter() + // .map(|user| { + // user.login + // .map(|l| l.0.to_string()) + // .unwrap_or("".to_string()) + // }) + // .collect::>() + // .join(",") + // }) + // .unwrap_or("".to_string()); + // let project_id = team + // .project_id + // .map(|project_id| project_id.to_string()) + // .unwrap_or("".to_string()); + // (user, project_id) + // } + // None => ("".to_string(), "".to_string()), + // }; + // let final_mark = match scale_team.final_mark { + // Some(final_mark) => final_mark.value().to_string(), + // None => "".to_string(), + // }; + // writeln!( + // file, + // "{}ㅣ{}ㅣ{}ㅣ{}ㅣ{}ㅣ{}ㅣ{}ㅣ{}ㅣ{}ㅣ{}ㅣ{}ㅣ{:?}ㅣ{:?}", + // project_id, + // scale_team.id, + // scale_team.created_at.0.to_utc(), + // scale_team.updated_at.0.to_utc(), + // final_mark, + // begin_at, + // corrector, + // correcteds, + // filled_at, + // truant, + // team_uesr, + // scale_team.comment, + // scale_team.feedback + // ) + // .expect("Failed to write record"); + // } + + println!("Output written to: {}", file_path); + Ok(()) +} + +async fn get_evaluation_historics( + result: &mut HashMap>, + id: &FtUserId, + page: &mut i32, +) -> ControlFlow<()> { + let token = FtApiToken::try_get(AuthInfo::build_from_env().unwrap()) + .await + .unwrap(); + let client = FtClient::new(FtClientReqwestConnector::new()); + let session = Arc::new(client.open_session(&token)); + let res = session + .users_id_correction_point_historics( + FtApiUsersIdCorrectionPointHistoricsRequest::new(*id) + .with_filter(vec![FtFilterOption::new( + FtFilterField::Sum, + vec!["-1".to_owned()], + )]) + .with_per_page(100) + .with_page(*page as u16), + ) + .await; + match res { + Ok(res) => { + if res.historics.is_empty() { + return ControlFlow::Break(()); + } + result.entry(*id).or_default().extend(res.historics); + *page += 1; + } + Err(FtClientError::RateLimitError(_)) => sleep(Duration::new(1, 42)).await, + Err(e) => { + eprintln!("other error: {e}"); + return ControlFlow::Break(()); + } + } + ControlFlow::Continue(()) +} + +async fn get_scale_teams( + result: &mut Vec, + page: &mut usize, + thread_num: usize, +) -> ControlFlow<()> { + let token = FtApiToken::try_get(AuthInfo::build_from_env().unwrap()) + .await + .unwrap(); + let client = FtClient::new(FtClientReqwestConnector::new()); + let session = Arc::new(client.open_session(&token)); + let res = session + .scale_teams( + FtApiScaleTeamsRequest::new() + .with_range(vec![FtRangeOption::new( + FtRangeField::CreatedAt, + vec!["2025-4-21".to_string(), "2025-4-25".to_string()], + )]) + .with_filter(vec![ + FtFilterOption::new(FtFilterField::CampusId, vec![GYEONGSAN.to_string()]), + FtFilterOption::new(FtFilterField::CursusId, vec![FT_CURSUS_ID.to_string()]), + ]) + .with_per_page(100) + .with_page(*page as u16), + ) + .await; + match res { + Ok(res) => { + if res.scale_teams.is_empty() { + return ControlFlow::Break(()); + } + result.extend(res.scale_teams); + *page += thread_num; + } + Err(FtClientError::RateLimitError(_)) => sleep(Duration::new(1, 42)).await, + Err(e) => { + eprintln!("other error: {e}"); + return ControlFlow::Break(()); + } + } + ControlFlow::Continue(()) +} diff --git a/libft-api/bin/get_user_ext.rs b/libft-api/bin/get_user_ext.rs new file mode 100644 index 0000000..8f2af78 --- /dev/null +++ b/libft-api/bin/get_user_ext.rs @@ -0,0 +1,113 @@ +use std::{collections::HashMap, io::Write, ops::ControlFlow, sync::Arc, time::Duration}; + +use chrono::Utc; +use libft_api::{campus_id::*, prelude::*, FT_PISCINE_CURSUS_ID}; +use rvstruct::ValueStruct; +use tokio::{sync::Semaphore, task::JoinSet, time::sleep}; +use tracing::info; + +#[tokio::main] +async fn main() -> Result<(), Box> { + tracing_subscriber::fmt::init(); + let thread_num = 8; + let permit = Arc::new(Semaphore::new(thread_num)); + + let ids = [ + 172410, 197482, 190887, 172305, 172353, 197422, 197429, 190783, 197456, 190848, 190815, + 172394, 174189, 190846, 174084, 190820, 172357, 190800, 197497, 172418, 172352, 172349, + 197528, 190909, 174169, 197496, 174101, 197397, 174128, 174104, 174127, 174112, 197454, + 174184, 197455, 197495, 197484, 172327, 197507, 190797, 197498, 197444, 174097, 190898, + 172325, 174113, 172307, 174153, 172346, 172356, 190862, 197402, 174156, 190839, 197518, + 197483, 174185, 174152, 174145, 197459, 197504, 174131, 190847, 197523, 197521, 197511, + 197406, 197403, 172364, 197486, 172362, 190795, 190802, 197525, 174188, 197457, 190806, + 174089, 174135, 174129, 197400, 190817, 174081, 174147, 197489, 172308, 197463, 190913, + 197437, 197605, 172400, 197516, 190885, 197449, 174161, 174186, 174110, 197439, 190838, + 172329, 190870, 172370, 174085, 174111, 190849, 172416, 190876, 197606, 197519, 174138, + 174149, 172413, 190845, 197527, 190895, 174168, 174137, 172414, 190832, 197537, 172375, + 197441, 174151, 190808, 197472, 172390, 197520, 190843, 172348, 172392, 190896, 172389, + 197448, 197417, 174139, 190907, 172335, 174095, 197494, 190910, 190816, 197445, 197541, + 174130, 174150, 190823, 197467, 190821, 190784, 190926, 174142, 197421, 197420, 174093, + 197435, 197453, 197530, 174102, 190886, 190861, 174103, 197447, 174123, 174099, 174096, + 174178, 172350, 197543, 197474, 174117, 172402, 172324, 172367, 190790, 197490, 190803, + 174133, 197529, 190855, 197428, 197542, 197499, 190837, 190865, 174154, 197547, 197501, + 190812, 190818, 197418, 172310, 190836, 197540, 172342, 190869, 197407, 197533, 190911, + 197487, 172318, 190903, 190831, 190937, 174109, 174115, 190854, 190866, 174181, 190813, + 174091, 172361, 172344, 190785, 197505, 197532, 197531, 172309, 172323, 174157, 197514, + 190791, 174105, 190810, 174183, 190794, 197395, 197458, 197481, 190905, 197412, 174086, + 197548, 197536, 172351, 190829, 174165, 197503, 172385, 172404, 197526, 172365, 197399, + 197538, 172401, 197409, 174119, 174083, 174177, 197539, 197432, 190874, 190844, 172319, + 174141, 190786, 174087, 172378, 190883, 172396, 174160, 190884, 174092, 174132, 197442, + 197398, 174190, 190853, 172330, 197413, 197469, 174094, 172366, 172368, 172322, 197427, + 174120, 197408, 197425, 172360, 197434, 172399, 173488, 151095, 212592, 212527, 212590, + 212600, 212458, 212489, 212601, 212464, 212628, 212493, 212582, 212591, 212469, 212456, + 212608, 212615, 212498, 212625, 212562, 212512, 212612, 212468, 212571, 212471, 212606, + 212560, 212525, 212501, 212572, 212587, 212452, 212460, 212496, 212557, 212476, 212529, + 212534, 212586, 212543, 212602, 212567, 212524, 212477, 212481, 212561, 212473, 212495, + 212522, 212570, 212517, 212538, 212539, 212459, 212462, 212544, 212482, 212558, 212559, + 212457, 212472, 212548, 212553, 212609, 212583, 212535, 212518, 212467, 212521, 212545, + 212533, 212568, 212595, 212505, 212465, 212503, 212499, 212514, 212624, 212466, 212454, + 212549, 212540, 212487, 212555, 212497, 212556, 212623, 212494, 212530, 212581, 212502, + 212510, 212546, 212579, + ] + .map(FtUserId::new); + + let mut users_task = JoinSet::new(); + for id in ids { + let permit = Arc::clone(&permit); + users_task.spawn(async move { + let _permit = permit.acquire().await.unwrap(); + loop { + if let ControlFlow::Break(result) = get_user_info(id).await { + break result; + } + } + }); + } + + let file_path = format!( + "/Users/hdoo/works/gsia/codes/libft-api/libft-api/bin/ft_cursus/info_{}.csv", + Utc::now().format("%Y-%m-%d_%H-%M-%S") + ); + + let mut file = std::fs::File::create(&file_path).expect("Failed to create output file"); + + file.write_all("user_id|login|level\n".as_bytes())?; + + let mut users = Vec::new(); + while let Some(Ok(Some(user))) = users_task.join_next().await { + users.push(user); + } + + std::fs::write( + "/Users/hdoo/works/gsia/codes/libft-api/libft-api/bin/ft_cursus/info_{}.csv", + serde_json::to_string_pretty(&users)?, + )?; + + println!("Output written to: {}", file_path); + Ok(()) +} + +async fn get_user_info(id: FtUserId) -> ControlFlow> { + let token = FtApiToken::try_get(AuthInfo::build_from_env().unwrap()) + .await + .unwrap(); + let client = FtClient::new(FtClientReqwestConnector::new()); + let session = Arc::new(client.open_session(&token)); + let res = session + .users_id(FtApiUsersIdRequest::new(FtUserIdentifier::UserId(id))) + .await; + + match res { + Ok(res) => ControlFlow::Break(Some(res.user)), + Err(e) => match e { + FtClientError::RateLimitError(ft_rate_limit_error) => { + sleep(Duration::new(1, 42)).await; + ControlFlow::Continue(()) + } + _ => { + tracing::error!("{:?}", e); + ControlFlow::Break(None) + } + }, + } +} diff --git a/libft-api/bin/location_stat.rs b/libft-api/bin/location_stat.rs new file mode 100644 index 0000000..d462198 --- /dev/null +++ b/libft-api/bin/location_stat.rs @@ -0,0 +1,128 @@ +use std::{collections::HashMap, io::Write, ops::Deref, sync::Arc}; + +use chrono::Utc; +use libft_api::prelude::*; +use tokio::{sync::Semaphore, task::JoinSet}; +use tracing::{debug, info}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + tracing_subscriber::fmt::init(); + let thread_num = 7; + let permit = Arc::new(Semaphore::new(thread_num)); + + // 3rd cohort piscine first round + // let ids = [ + // 212531, 212530, 212529, 212528, 212527, 212526, 212525, 212524, 212523, 212522, 212521, + // 212520, 212519, 212518, 212517, 212516, 212515, 212514, 212513, 212512, 212511, 212510, + // 212509, 212508, 212507, 212506, 212505, 212504, 212503, 212502, 212501, 212500, 212499, + // 212498, 212497, 212496, 212495, 212494, 212493, 212492, 212491, 212490, 212489, 212488, + // 212487, 212486, 212485, 212484, 212483, 212482, 212481, 212480, 212479, 212478, 212477, + // 212476, 212475, 212474, 212473, 212472, 212471, 212470, 212469, 212468, 212467, 212466, + // 212465, 212464, 212463, 212462, 212461, 212460, 212459, 212458, 212457, 212456, 212455, + // 212454, 212453, 212452, 212638, 212637, 212629, 212628, 212627, 212626, 212625, 212624, + // 212623, 212622, 212621, 212620, 212619, 212618, 212617, 212616, 212615, 212614, 212613, + // 212612, 212611, 212610, 212609, 212608, 212607, 212606, 212605, 212604, 212603, 212602, + // 212601, 212600, 212599, 212598, 212597, 212596, 212595, 212594, 212593, 212592, 212591, + // 212590, 212589, 212588, 212587, 212586, 212585, 212584, 212583, 212582, 212581, 212580, + // 212579, 212578, 212577, 212576, 212575, 212574, 212573, 212572, 212571, 212570, 212569, + // 212568, 212567, 212566, 212565, 212564, 212563, 212562, 212561, 212560, 212559, 212558, + // 212557, 212556, 212555, 212554, 212553, 212552, 212551, 212550, 212549, 212548, 212547, + // 212546, 212545, 212544, 212543, 212542, 212541, 212540, 212539, 212538, 212537, 212536, + // 212535, 212534, 212533, 212532, + // ] + // .map(FtUserId::new); + + let ids = [ + 172410, 197482, 190887, 172305, 172353, 197422, 197429, 190783, 197456, 190848, 190815, + 172394, 174189, 190846, 174084, 190820, 172357, 190800, 197497, 172418, 172352, 172349, + 197528, 190909, 174169, 197496, 174101, 197397, 174128, 174104, 174127, 174112, 197454, + 174184, 197455, 197495, 197484, 172327, 197507, 190797, 197498, 197444, 174097, 190898, + 172325, 174113, 172307, 174153, 172346, 172356, 190862, 197402, 174156, 190839, 197518, + 197483, 174185, 174152, 174145, 197459, 197504, 174131, 190847, 197523, 197521, 197511, + 197406, 197403, 172364, 197486, 172362, 190795, 190802, 197525, 174188, 197457, 190806, + 174089, 174135, 174129, 197400, 190817, 174081, 174147, 197489, 172308, 197463, 190913, + 197437, 197605, 172400, 197516, 190885, 197449, 174161, 174186, 174110, 197439, 190838, + 172329, 190870, 172370, 174085, 174111, 190849, 172416, 190876, 197606, 197519, 174138, + 174149, 172413, 190845, 197527, 190895, 174168, 174137, 172414, 190832, 197537, 172375, + 197441, 174151, 190808, 197472, 172390, 197520, 190843, 172348, 172392, 190896, 172389, + 197448, 197417, 174139, 190907, 172335, 174095, 197494, 190910, 190816, 197445, 197541, + 174130, 174150, 190823, 197467, 190821, 190784, 190926, 174142, 197421, 197420, 174093, + 197435, 197453, 197530, 174102, 190886, 190861, 174103, 197447, 174123, 174099, 174096, + 174178, 172350, 197543, 197474, 174117, 172402, 172324, 172367, 190790, 197490, 190803, + 174133, 197529, 190855, 197428, 197542, 197499, 190837, 190865, 174154, 197547, 197501, + 190812, 190818, 197418, 172310, 190836, 197540, 172342, 190869, 197407, 197533, 190911, + 197487, 172318, 190903, 190831, 190937, 174109, 174115, 190854, 190866, 174181, 190813, + 174091, 172361, 172344, 190785, 197505, 197532, 197531, 172309, 172323, 174157, 197514, + 190791, 174105, 190810, 174183, 190794, 197395, 197458, 197481, 190905, 197412, 174086, + 197548, 197536, 172351, 190829, 174165, 197503, 172385, 172404, 197526, 172365, 197399, + 197538, 172401, 197409, 174119, 174083, 174177, 197539, 197432, 190874, 190844, 172319, + 174141, 190786, 174087, 172378, 190883, 172396, 174160, 190884, 174092, 174132, 197442, + 197398, 174190, 190853, 172330, 197413, 197469, 174094, 172366, 172368, 172322, 197427, + 174120, 197408, 197425, 172360, 197434, 172399, 173488, + ] + .map(FtUserId::new); + + Ok(()) +} + +async fn save_location_stat( + ids: Arc>, + permit: Arc, +) -> Result<(), Box> { + let mut handles = JoinSet::new(); + + for id in ids.clone().deref().clone() { + let permit = Arc::clone(&permit); + handles.spawn(async move { + let _permit = permit.acquire().await.unwrap(); + loop { + if let Ok(res) = get_location_stat(&id).await { + debug!("{id}: {:?}", res.stats.len()); + break (id, res); + } + } + }); + } + + let mut location_stats = HashMap::new(); + while let Some(Ok((id, res))) = handles.join_next().await { + location_stats.entry(id).or_insert(res); + info!("{}", location_stats.len()); + } + + let file_path = format!( + "/Users/hdoo/works/gsia/codes/libft-api/libft-api/bin/piscine/third_cohort/first_round/location_stats_{}.csv", + Utc::now().format("%Y-%m-%d_%H-%M-%S") + ); + + let mut file = std::fs::File::create(&file_path).expect("Failed to create output file"); + + file.write_all("intra_id,date,time\n".as_bytes())?; + + for (intra_id, location_stat) in location_stats { + for (date, time) in location_stat.stats { + writeln!(file, "{},{},{}", intra_id, date, time).expect("Failed to write record"); + } + } + + println!("Output written to: {}", file_path); + Ok(()) +} + +async fn get_location_stat(id: &FtUserId) -> ClientResult { + let token = FtApiToken::try_get(AuthInfo::build_from_env().unwrap()) + .await + .unwrap(); + let client = FtClient::new(FtClientReqwestConnector::new()); + let session = Arc::new(client.open_session(&token)); + let res = session + .users_id_locations_stats( + FtApiUsersIdLocationsStatsRequest::new(id.clone()) + .with_begin_at("2024-1-1".parse().unwrap()) + .with_end_at("2025-3-1".parse().unwrap()), + ) + .await; + debug!("{:?}", res); + res +} diff --git a/libft-api/bin/teams.rs b/libft-api/bin/teams.rs new file mode 100644 index 0000000..a24938d --- /dev/null +++ b/libft-api/bin/teams.rs @@ -0,0 +1,110 @@ +use std::{io::Write, sync::Arc}; + +use chrono::{TimeDelta, TimeZone, Utc}; +use ft_project_session_ids::c_piscine::C_PISCINE_RUSH_02; +use libft_api::{campus_id::*, prelude::*, FT_PISCINE_CURSUS_ID}; +use rvstruct::ValueStruct; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let begin_at = Utc.with_ymd_and_hms(2025, 1, 28, 7, 0, 0).unwrap(); + let body = vec![ + FtApiScaleTeamsMultipleCreateBody { + begin_at: FtDateTimeUtc::new(begin_at.clone()), + user_id: FtUserId::new(174094), + team_id: FtTeamId::new(6298862), + }, + FtApiScaleTeamsMultipleCreateBody { + begin_at: FtDateTimeUtc::new(begin_at), + user_id: FtUserId::new(172309), + team_id: FtTeamId::new(6298846), + }, + ]; + let res = post_scale_team(body).await.unwrap(); + println!("{res:?}"); + + Ok(()) +} + +async fn temp() { + tracing_subscriber::fmt::init(); + + let evaluators = [174094, 172309].map(FtUserId::new); + + let project_teams = get_project_teams( + FtProjectSessionId::new(C_PISCINE_RUSH_02), + "2025-1-20".to_string(), + "2025-2-15".to_string(), + ) + .await + .teams; + + project_teams + .iter() + .for_each(|teams| println!("{}|{:?}", teams.id, teams.users)); + + let begin_at = Utc.with_ymd_and_hms(2025, 1, 28, 5, 0, 0).unwrap(); + let mut bodys = Vec::new(); + for (i, project_team) in project_teams.iter().enumerate() { + let evaluator = evaluators.get(i % evaluators.len()).unwrap().clone(); + let iter = i / evaluators.len(); + let begin_at = begin_at + .checked_add_signed(TimeDelta::new(iter as i64 * 60 * 60 * 1, 0).unwrap()) + .map(FtDateTimeUtc::new) + .unwrap(); + bodys.push(FtApiScaleTeamsMultipleCreateBody { + begin_at, + user_id: evaluator, + team_id: project_team.id.clone(), + }); + } + + for ele in bodys.iter() { + println!("{},{},{}", ele.user_id, ele.team_id, ele.begin_at.value()); + } +} + +async fn post_scale_team( + bodys: Vec, +) -> Result { + let token = FtApiToken::try_get(AuthInfo::build_from_env().unwrap()) + .await + .unwrap(); + let client = FtClient::new(FtClientReqwestConnector::new()); + let session = Arc::new(client.open_session(&token)); + + session + .scale_teams_multiple_create_post(FtApiScaleTeamsMultipleCreateRequest::new(bodys)) + .await +} + +async fn get_project_teams( + project_session_id: FtProjectSessionId, + begin_at: String, + end_at: String, +) -> FtApiProjectSessionsTeamsResponse { + let token = FtApiToken::try_get(AuthInfo::build_from_env().unwrap()) + .await + .unwrap(); + let client = FtClient::new(FtClientReqwestConnector::new()); + let session = Arc::new(client.open_session(&token)); + let res = session + .project_sessions_id_teams( + FtApiProjectSessionsTeamsRequest::new(project_session_id) + .with_per_page(100) + .with_filter(vec![ + FtFilterOption::new(FtFilterField::Campus, vec![GYEONGSAN.to_string()]), + FtFilterOption::new( + FtFilterField::Cursus, + vec![FT_PISCINE_CURSUS_ID.to_string()], + ), + ]) + .with_range(vec![FtRangeOption::new( + FtRangeField::CreatedAt, + vec![begin_at, end_at], + )]), + ) + .await; + + res.unwrap() +} diff --git a/libft-api/src/models/achievement.rs b/libft-api/src/models/achievement.rs index 1a8197d..676c836 100644 --- a/libft-api/src/models/achievement.rs +++ b/libft-api/src/models/achievement.rs @@ -34,13 +34,13 @@ pub struct FtAchievementUsersUrl(pub FtUrl); #[derive(Debug, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct FtAchievement { - pub id: FtAchievementId, - pub name: FtAchievementName, - pub description: FtAchievementDescription, - pub tier: FtAchievementTier, - pub kind: FtAchievementKind, - pub visible: bool, - pub image: FtAchievementImage, + pub id: Option, + pub name: Option, + pub description: Option, + pub tier: Option, + pub kind: Option, + pub visible: Option, + pub image: Option, pub nbr_of_success: Option, - pub users_url: FtAchievementUsersUrl, + pub users_url: Option, }