This commit is contained in:
Dominic Grimm 2023-01-27 18:31:44 +01:00
parent 171df04dad
commit 80470c2fc9
No known key found for this signature in database
GPG key ID: 6F294212DEAAC530

View file

@ -738,13 +738,21 @@ impl Client {
} }
pub async fn student_reports(&self, class_id: i32) -> Result<()> { pub async fn student_reports(&self, class_id: i32) -> Result<()> {
#[derive(Deserialize, Debug)]
struct Data {
finished: bool,
error: bool,
#[serde(rename = "reportParams")]
report_params: String,
}
let mut url = self.webuntis_url.join("reports.do")?; let mut url = self.webuntis_url.join("reports.do")?;
url.query_pairs_mut() url.query_pairs_mut()
.append_pair("name", "Student") .append_pair("name", "Student")
.append_pair("format", "csv") .append_pair("format", "csv")
.append_pair("klasseId", &class_id.to_string()) .append_pair("klasseId", &class_id.to_string())
.append_pair("studentsForDate", "true"); .append_pair("studentsForDate", "true");
let resp = reqwest::Client::new() let resp: Data = reqwest::Client::new()
.get(url) .get(url)
.header(reqwest::header::USER_AGENT, &self.user_agent) .header(reqwest::header::USER_AGENT, &self.user_agent)
.header(reqwest::header::ACCEPT, "application/json") .header(reqwest::header::ACCEPT, "application/json")
@ -757,8 +765,10 @@ impl Client {
Client::construct_bearer(&self.authorization.as_ref().context("Not logged in")?), Client::construct_bearer(&self.authorization.as_ref().context("Not logged in")?),
) )
.send() .send()
.await?
.json()
.await?; .await?;
dbg!(resp.text().await?); dbg!(resp);
Ok(()) Ok(())
} }