use crate::openproject::client::{handle_response_status, Client, OpenProjectError}; use crate::openproject::hal::HalEntity; use serde::Deserialize; #[derive(Deserialize, Debug)] pub struct User { pub href: String, pub title: String, } #[derive(Deserialize, Debug)] pub struct Links { pub user: User, } #[derive(Deserialize, Debug)] pub struct Root { #[serde(rename = "instanceName")] pub instance_name: String, #[serde(rename = "_links")] pub links: Links, #[serde(flatten)] pub hal_entity: HalEntity, } pub trait RootClient { async fn root(&self) -> Result; } impl RootClient for Client { async fn root(&self) -> Result { let client = reqwest::Client::new(); let response = client .get(format!("{}/api/v3", self.base_url)) .basic_auth("apikey", Some(&self.token)) .send() .await?; let r = handle_response_status(response, "Error while retrieving root").await?; Ok(r) } }