From a05241dd8e30d79e874925c68c43f23bbbba44b5 Mon Sep 17 00:00:00 2001 From: Flori Weber Date: Sun, 18 Jun 2023 23:10:29 +0200 Subject: [PATCH] Add remove_relationship --- src/api/users/relationships.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/api/users/relationships.rs b/src/api/users/relationships.rs index 7ad76fe..65c044e 100644 --- a/src/api/users/relationships.rs +++ b/src/api/users/relationships.rs @@ -130,4 +130,24 @@ impl UserMeta { RelationshipType::Suggestion | RelationshipType::Implicit => None, } } + + /// Removes the relationship between the authenticated user and the specified user. + /// + /// # Arguments + /// + /// * `user_id` - A string slice that holds the ID of the user to remove the relationship with. + /// + /// # Returns + /// This function returns an [`Option`] that holds a [`ChorusLibError`] if the request fails. + pub async fn remove_relationship(&mut self, user_id: &str) -> Option { + let belongs_to = self.belongs_to.borrow(); + let url = format!( + "{}/users/@me/relationships/{}/", + belongs_to.urls.get_api(), + user_id + ); + drop(belongs_to); + let request = Client::new().post(url).bearer_auth(self.token()); + handle_request_as_option(request, self, crate::api::limits::LimitType::Global).await + } }