From aa89168928c0e513ef84defe30afc4e90b0534c9 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 6 May 2023 22:47:26 +0200 Subject: [PATCH 1/6] add mod.rs --- src/api/users/mod.rs | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/api/users/mod.rs diff --git a/src/api/users/mod.rs b/src/api/users/mod.rs new file mode 100644 index 0000000..e69de29 From 7211ff5eb30129de00978581d414482ee0915f4a Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 6 May 2023 22:47:31 +0200 Subject: [PATCH 2/6] add pronouns --- src/api/types.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/types.rs b/src/api/types.rs index 5dafe1e..e218a83 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -150,6 +150,7 @@ pub struct UserObject { email: Option, flags: i8, premium_type: Option, + pronouns: Option, public_flags: Option, } From 70a426c75491a2e0f2533aacd324b1f9381ec039 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 7 May 2023 00:17:54 +0200 Subject: [PATCH 3/6] Add users to mod.rs --- src/api/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/mod.rs b/src/api/mod.rs index 882f9bd..eb12765 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -3,6 +3,7 @@ pub mod channels; pub mod policies; pub mod schemas; pub mod types; +pub mod users; pub use channels::messages::*; pub use policies::instance::instance::*; From 45d5505e2c25a0106fda57c8641fc8493a27d049 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 7 May 2023 00:18:06 +0200 Subject: [PATCH 4/6] remove nesting layer --- src/api/policies/instance/instance.rs | 59 +++++++++++++-------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/src/api/policies/instance/instance.rs b/src/api/policies/instance/instance.rs index f7a5653..19e841e 100644 --- a/src/api/policies/instance/instance.rs +++ b/src/api/policies/instance/instance.rs @@ -1,41 +1,38 @@ -pub mod instance { - use reqwest::Client; - use serde_json::from_str; - use crate::errors::InstanceServerError; - use crate::{api::types::InstancePolicies, instance::Instance}; +use reqwest::Client; +use serde_json::from_str; - impl<'a> Instance<'a> { - /** - Gets the instance policies schema. - # Errors - [`InstanceServerError`] - If the request fails. - */ - pub async fn instance_policies_schema( - &self, - ) -> Result { - let client = Client::new(); - let endpoint_url = self.urls.get_api().to_string() + "/policies/instance/"; - let request = match client.get(&endpoint_url).send().await { - Ok(result) => result, - Err(e) => { - return Err(InstanceServerError::RequestErrorError { - url: endpoint_url, - error: e.to_string(), - }); - } - }; +use crate::errors::InstanceServerError; +use crate::{api::types::InstancePolicies, instance::Instance}; - if !request.status().as_str().starts_with('2') { - return Err(InstanceServerError::ReceivedErrorCodeError { - error_code: request.status().to_string(), +impl<'a> Instance<'a> { + /** + Gets the instance policies schema. + # Errors + [`InstanceServerError`] - If the request fails. + */ + pub async fn instance_policies_schema(&self) -> Result { + let client = Client::new(); + let endpoint_url = self.urls.get_api().to_string() + "/policies/instance/"; + let request = match client.get(&endpoint_url).send().await { + Ok(result) => result, + Err(e) => { + return Err(InstanceServerError::RequestErrorError { + url: endpoint_url, + error: e.to_string(), }); } + }; - let body = request.text().await.unwrap(); - let instance_policies_schema: InstancePolicies = from_str(&body).unwrap(); - Ok(instance_policies_schema) + if !request.status().as_str().starts_with('2') { + return Err(InstanceServerError::ReceivedErrorCodeError { + error_code: request.status().to_string(), + }); } + + let body = request.text().await.unwrap(); + let instance_policies_schema: InstancePolicies = from_str(&body).unwrap(); + Ok(instance_policies_schema) } } From 3e6e8b78125f59807a8e14fb01fff35a21d01ea0 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 7 May 2023 00:18:14 +0200 Subject: [PATCH 5/6] add users to mod.rs --- src/api/users/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/users/mod.rs b/src/api/users/mod.rs index e69de29..3bad41b 100644 --- a/src/api/users/mod.rs +++ b/src/api/users/mod.rs @@ -0,0 +1,3 @@ +pub mod users; + +pub use users::*; From df850b33d5239b36f46f3cc80d443e1643da5353 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 7 May 2023 00:18:21 +0200 Subject: [PATCH 6/6] add test fn --- src/api/users/users.rs | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/api/users/users.rs diff --git a/src/api/users/users.rs b/src/api/users/users.rs new file mode 100644 index 0000000..0190944 --- /dev/null +++ b/src/api/users/users.rs @@ -0,0 +1 @@ +pub fn doathing() {}