1use crate::client::HingeClient;
2use crate::errors::HingeError;
3use crate::models::{
4 AccountInfo, AnswerContentPayload, AuthSettings, ExportStatus, NotificationSettings,
5 Preferences, PreferencesResponse, UserSettings, UserTrait,
6};
7use crate::storage::Storage;
8
9pub struct SettingsApi<'a, S: Storage + Clone> {
10 pub(super) client: &'a mut HingeClient<S>,
11}
12
13impl<S: Storage + Clone> SettingsApi<'_, S> {
14 pub async fn preferences(&self) -> Result<PreferencesResponse, HingeError> {
15 self.client.get_self_preferences().await
16 }
17
18 pub async fn update_preferences(
19 &self,
20 preferences: Preferences,
21 ) -> Result<serde_json::Value, HingeError> {
22 self.client.update_self_preferences(preferences).await
23 }
24
25 pub async fn content(&self) -> Result<UserSettings, HingeError> {
26 self.client.get_content_settings().await
27 }
28
29 pub async fn update_content(
30 &self,
31 settings: UserSettings,
32 ) -> Result<serde_json::Value, HingeError> {
33 self.client.update_content_settings(settings).await
34 }
35
36 pub async fn update_answers(
37 &self,
38 answers: Vec<AnswerContentPayload>,
39 ) -> Result<serde_json::Value, HingeError> {
40 self.client.update_answers(answers).await
41 }
42
43 pub async fn auth(&self) -> Result<AuthSettings, HingeError> {
44 self.client.get_auth_settings().await
45 }
46
47 pub async fn notifications(&self) -> Result<NotificationSettings, HingeError> {
48 self.client.get_notification_settings().await
49 }
50
51 pub async fn user_traits(&self) -> Result<Vec<UserTrait>, HingeError> {
52 self.client.get_user_traits().await
53 }
54
55 pub async fn account_info(&self) -> Result<AccountInfo, HingeError> {
56 self.client.get_account_info().await
57 }
58
59 pub async fn export_status(&self) -> Result<ExportStatus, HingeError> {
60 self.client.get_export_status().await
61 }
62}