Skip to main content

hinge_rs/api/
profiles.rs

1use crate::client::HingeClient;
2use crate::errors::HingeError;
3use crate::models::{
4    ProfileContentFull, ProfileUpdate, PublicUserProfile, SelfContentResponse, SelfProfileResponse,
5};
6use crate::storage::Storage;
7
8pub struct ProfilesApi<'a, S: Storage + Clone> {
9    pub(super) client: &'a mut HingeClient<S>,
10}
11
12impl<S: Storage + Clone> ProfilesApi<'_, S> {
13    pub async fn rendered_text_for_user(&mut self, user_id: &str) -> Result<String, HingeError> {
14        self.client.rendered_profile_text_for_user(user_id).await
15    }
16
17    pub async fn me(&self) -> Result<SelfProfileResponse, HingeError> {
18        self.client.get_self_profile().await
19    }
20
21    pub async fn content(&self) -> Result<SelfContentResponse, HingeError> {
22        self.client.get_self_content().await
23    }
24
25    pub async fn public(
26        &self,
27        user_ids: Vec<String>,
28    ) -> Result<Vec<PublicUserProfile>, HingeError> {
29        self.client.get_profiles(user_ids).await
30    }
31
32    pub async fn public_raw_unfiltered(
33        &self,
34        user_ids: Vec<String>,
35    ) -> Result<serde_json::Value, HingeError> {
36        self.client
37            .get_profiles_public_raw_unfiltered(user_ids)
38            .await
39    }
40
41    pub async fn public_content(
42        &self,
43        user_ids: Vec<String>,
44    ) -> Result<Vec<ProfileContentFull>, HingeError> {
45        self.client.get_profile_content(user_ids).await
46    }
47
48    pub async fn public_content_raw_unfiltered(
49        &self,
50        user_ids: Vec<String>,
51    ) -> Result<serde_json::Value, HingeError> {
52        self.client
53            .get_content_public_raw_unfiltered(user_ids)
54            .await
55    }
56
57    pub async fn update(&self, update: ProfileUpdate) -> Result<serde_json::Value, HingeError> {
58        self.client.update_self_profile(update).await
59    }
60
61    pub async fn delete_content(&self, content_ids: Vec<String>) -> Result<(), HingeError> {
62        self.client.delete_content(content_ids).await
63    }
64}