impl get_settings()
This commit is contained in:
parent
f06b43a8fe
commit
a7514a28c6
|
@ -1,7 +1,10 @@
|
||||||
|
use reqwest::Client;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
api::{
|
api::{
|
||||||
limits::Limits,
|
limits::Limits,
|
||||||
types::{User, UserObject},
|
types::{User, UserObject},
|
||||||
|
UserSettings,
|
||||||
},
|
},
|
||||||
errors::InstanceServerError,
|
errors::InstanceServerError,
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
|
@ -45,6 +48,29 @@ impl<'a> User<'a> {
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_settings(
|
||||||
|
token: &String,
|
||||||
|
url_api: &String,
|
||||||
|
instance_limits: &mut Limits,
|
||||||
|
) -> Result<UserSettings, InstanceServerError> {
|
||||||
|
let request: reqwest::RequestBuilder = Client::new()
|
||||||
|
.get(format!("{}/users/@me/settings/", url_api))
|
||||||
|
.bearer_auth(token);
|
||||||
|
let mut requester = crate::limit::LimitedRequester::new().await;
|
||||||
|
match requester
|
||||||
|
.send_request(
|
||||||
|
request,
|
||||||
|
crate::api::limits::LimitType::Ip,
|
||||||
|
instance_limits,
|
||||||
|
&mut Limits::default(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(result) => Ok(serde_json::from_str(&result.text().await.unwrap()).unwrap()),
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
|
@ -75,7 +101,6 @@ impl Instance {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn get_user() {}
|
async fn get_user() {}
|
||||||
|
|
Loading…
Reference in New Issue