From 28881276e066278cf5f12c488f1a11462a7ae9c7 Mon Sep 17 00:00:00 2001 From: Flori Weber Date: Wed, 14 Jun 2023 22:54:14 +0200 Subject: [PATCH] Add get_mutual_relationships --- src/api/users/relationships.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/api/users/relationships.rs b/src/api/users/relationships.rs index 8b13789..d286ef6 100644 --- a/src/api/users/relationships.rs +++ b/src/api/users/relationships.rs @@ -1 +1,33 @@ +use reqwest::Client; +use crate::{api::deserialize_response, errors::ChorusLibError, instance::UserMeta, types}; + +impl UserMeta { + /// Retrieves the mutual relationships between the authenticated user and the specified user. + /// + /// # Arguments + /// + /// * `user_id` - A string slice that holds the ID of the user to retrieve the mutual relationships with. + /// + /// # Returns + /// This function returns a [`Option>>`]. + pub async fn get_mutual_relationships( + &mut self, + user_id: &str, + ) -> Result>, ChorusLibError> { + let belongs_to = self.belongs_to.borrow(); + let url = format!( + "{}/users/{}/relationships/", + belongs_to.urls.get_api(), + user_id + ); + drop(belongs_to); + let request = Client::new().get(url).bearer_auth(self.token()); + deserialize_response::>>( + request, + self, + crate::api::limits::LimitType::Global, + ) + .await + } +}