From 0ad1739d4f94fafe458e1bd11bab376e12cbc3c8 Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Fri, 27 Jan 2023 12:57:03 +0100 Subject: [PATCH] Update --- src/lib.rs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7c4a9a9..96bd88f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -283,9 +283,6 @@ struct ApiTeachersResponse { data: ApiTeachersResponseData, } -#[derive(Deserialize, Debug)] -pub struct ApiProfile {} - #[derive(Debug)] pub struct Client { pub api_url: url::Url, @@ -736,6 +733,39 @@ impl Client { Ok(resp.data.elements) } + pub async fn students(&self) -> Result<()> { + let resp = reqwest::Client::new() + .get(self.rpc_url.as_str()) + .header(reqwest::header::USER_AGENT, &self.user_agent) + .header(reqwest::header::CONTENT_TYPE, "application/json") + .header(reqwest::header::ACCEPT, "application/json") + .header( + reqwest::header::COOKIE, + self.session.as_ref().context("Not logged in")?, + ) + .json(&json!({ + "id": "ID", + "method": "getStudents", + "params": {}, + "jsonrpc": "2.0" + })) + .send() + .await?; + // .json() + // .await?; + // if let Some(e) = resp.error { + // bail!("RPC error: {:?}", e); + // } + dbg!(resp.text().await?); + + // if let Some(x) = resp.result { + // Ok(x) + // } else { + // bail!("RPC result is null"); + // } + Ok(()) + } + // pub async fn exams(&self) -> Result<()> { // Ok(()) // }