This commit is contained in:
Dominic Grimm 2023-01-27 19:28:34 +01:00
parent b3b194cb7c
commit e1515ea207
No known key found for this signature in database
GPG key ID: 6F294212DEAAC530

View file

@ -284,6 +284,15 @@ struct ApiTeachersResponse {
data: ApiTeachersResponseData, data: ApiTeachersResponseData,
} }
#[derive(Deserialize, Debug)]
pub struct ApiReportStudent {
pub name: String,
#[serde(rename = "longName")]
pub long_name: String,
#[serde(rename = "foreName")]
pub fore_name: String,
}
#[derive(Debug)] #[derive(Debug)]
pub struct Client { pub struct Client {
pub webuntis_url: Url, pub webuntis_url: Url,
@ -737,7 +746,7 @@ impl Client {
Ok(resp.data.elements) Ok(resp.data.elements)
} }
pub async fn student_reports(&self, class_id: i32) -> Result<()> { pub async fn student_reports(&self, class_id: i32) -> Result<Vec<ApiReportStudent>> {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
struct Data { struct Data {
finished: bool, finished: bool,
@ -810,11 +819,9 @@ impl Client {
let mut reader = csv::ReaderBuilder::new() let mut reader = csv::ReaderBuilder::new()
.delimiter(b'\t') .delimiter(b'\t')
.from_reader(records.as_bytes()); .from_reader(records.as_bytes());
for record in reader.records() {
let record = record?;
dbg!(record);
}
Ok(()) Ok(reader
.deserialize::<ApiReportStudent>()
.collect::<Result<Vec<_>, _>>()?)
} }
} }