1use crate::api::client::TweetyClient;
2use crate::api::error::TweetyError;
3use crate::types::types::ResponseWithHeaders;
4use reqwest::Method;
5
6impl TweetyClient {
7 pub async fn unlike_tweet(
11 &self,
12 user_id: u64,
13 tweet_id: u64,
14 ) -> Result<ResponseWithHeaders, TweetyError> {
15 let url = format!(
16 "https://api.x.com/2/tweets/:{}/likes/:{}",
17 user_id, tweet_id
18 );
19
20 self.send_request::<()>(&url, Method::DELETE, None).await
21 }
22 pub async fn get_users_who_liked_a_post(
25 &self,
26 post_id: &str,
27 ) -> Result<ResponseWithHeaders, TweetyError> {
28 let url = format!("https://api.x.com/2/tweets/{}/liking_users", post_id);
29
30 self.send_request::<()>(&url, Method::GET, None).await
31 }
32
33 pub async fn get_posts_liked_by_a_user(
36 &self,
37 user_id: &str,
38 ) -> Result<ResponseWithHeaders, TweetyError> {
39 let url = format!("https://api.x.com/2/users/{}/liked_tweets", user_id);
40
41 self.send_request::<()>(&url, Method::GET, None).await
42 }
43 pub async fn like_a_post(&self, user_id: &str) -> Result<ResponseWithHeaders, TweetyError> {
48 let url = format!("https://api.x.com/2/users/{}/likes", user_id);
49
50 self.send_request::<()>(&url, Method::POST, None).await
51 }
52
53 pub async fn unlike_a_post(
56 &self,
57 user_id: &str,
58 tweet_id: &str,
59 ) -> Result<ResponseWithHeaders, TweetyError> {
60 let url = format!("https://api.x.com/2/users/{}/likes/{}", user_id, tweet_id);
61
62 self.send_request::<()>(&url, Method::DELETE, None).await
63 }
64}