mastodon_api\methods/
endorsements.rs

1use crate::MastodonClient;
2use crate::error::Result;
3use crate::models::Account;
4
5/// Handler for endorsements (pinned accounts on profile).
6pub struct EndorsementsHandler<'a> {
7    client: &'a MastodonClient,
8}
9
10impl<'a> EndorsementsHandler<'a> {
11    /// Creates a new `EndorsementsHandler` for the given client.
12    pub fn new(client: &'a MastodonClient) -> Self {
13        Self { client }
14    }
15
16    /// Fetches all accounts that the authenticated user is currently endorsing.
17    ///
18    /// Returns:
19    /// - `Result<Vec<Account>>`: The endorsed accounts.
20    ///
21    /// Corresponds to `GET /api/v1/endorsements`.
22    pub async fn list(&self) -> Result<Vec<Account>> {
23        let url = format!("{}/api/v1/endorsements", self.client.base_url());
24        let req = self.client.http_client().get(&url);
25        self.client.send(req).await
26    }
27}