From 5d5724cac1d7553ba6fff2bdcca87d140578aa90 Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Fri, 27 Jan 2023 12:41:33 +0100 Subject: [PATCH] Update --- src/lib.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6b876c8..2061932 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -283,6 +283,9 @@ struct ApiTeachersResponse { data: ApiTeachersResponseData, } +#[derive(Deserialize, Debug)] +pub struct ApiProfile {} + #[derive(Debug)] pub struct Client { pub api_url: url::Url, @@ -733,7 +736,27 @@ impl Client { Ok(resp.data.elements) } - pub async fn exams(&self) -> Result<()> { - Ok(()) + // pub async fn exams(&self) -> Result<()> { + // Ok(()) + // } + + pub async fn profile(&self) -> Result { + let resp = reqwest::Client::new() + .get(self.api_url.join("profile/general")?) + .header(reqwest::header::USER_AGENT, &self.user_agent) + .header(reqwest::header::ACCEPT, "application/json") + .header( + reqwest::header::COOKIE, + self.session.as_ref().context("Not logged in")?, + ) + .header( + reqwest::header::AUTHORIZATION, + Client::construct_bearer(&self.authorization.as_ref().context("Not logged in")?), + ) + .send() + .await?; + dbg!(resp.text().await?); + + Ok(ApiProfile {}) } }