mastodon_api\methods/
preferences.rs

1use crate::MastodonClient;
2use crate::error::Result;
3use crate::models::preferences::Preferences;
4
5/// Handler for preference-related API endpoints.
6pub struct PreferencesHandler<'a> {
7    client: &'a MastodonClient,
8}
9
10impl<'a> PreferencesHandler<'a> {
11    /// Creates a new `PreferencesHandler` for the given client.
12    pub fn new(client: &'a MastodonClient) -> Self {
13        Self { client }
14    }
15
16    /// Fetches the authenticated user's preferences.
17    ///
18    /// Returns:
19    /// - `Result<Preferences>`: The user's preferences.
20    ///
21    /// Corresponds to `GET /api/v1/preferences`.
22    pub async fn get(&self) -> Result<Preferences> {
23        let url = format!("{}/api/v1/preferences", self.client.base_url());
24        let req = self.client.http_client().get(&url);
25        self.client.send(req).await
26    }
27}