gewe_http/moments/
settings.rs1use crate::client::GeweHttpClient;
2use gewe_core::{
3 GeweError, SetSnsPrivacyRequest, SetSnsVisibleScopeRequest, StrangerVisibilityRequest,
4};
5use tracing::instrument;
6
7impl GeweHttpClient {
8 #[instrument(skip(self))]
9 pub async fn set_stranger_visibility(
10 &self,
11 req: StrangerVisibilityRequest<'_>,
12 ) -> Result<(), GeweError> {
13 let _ = self
14 .post_api::<_, ()>("gewe/v2/api/sns/strangerVisibilityEnabled", &req)
15 .await?;
16 Ok(())
17 }
18
19 #[instrument(skip(self))]
20 pub async fn set_sns_visible_scope(
21 &self,
22 req: SetSnsVisibleScopeRequest<'_>,
23 ) -> Result<(), GeweError> {
24 let _ = self
25 .post_api::<_, ()>("gewe/v2/api/sns/snsVisibleScope", &req)
26 .await?;
27 Ok(())
28 }
29
30 #[instrument(skip(self))]
31 pub async fn set_sns_privacy(&self, req: SetSnsPrivacyRequest<'_>) -> Result<(), GeweError> {
32 let _ = self
33 .post_api::<_, ()>("gewe/v2/api/sns/snsSetPrivacy", &req)
34 .await?;
35 Ok(())
36 }
37}
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42
43 #[test]
44 fn test_set_stranger_visibility_request() {
45 let req = StrangerVisibilityRequest {
46 app_id: "test_app",
47 enabled: true,
48 };
49 let json = serde_json::to_string(&req).expect("Failed to serialize");
50 assert!(json.contains("appId"));
51 assert!(json.contains("enabled"));
52 }
53
54 #[test]
55 fn test_set_sns_visible_scope_request() {
56 let req = SetSnsVisibleScopeRequest {
57 app_id: "test_app",
58 option: 0,
59 };
60 let json = serde_json::to_string(&req).expect("Failed to serialize");
61 assert!(json.contains("appId"));
62 assert!(json.contains("option"));
63 }
64
65 #[test]
66 fn test_set_sns_privacy_request() {
67 let req = SetSnsPrivacyRequest {
68 app_id: "test_app",
69 sns_id: 123456,
70 open: true,
71 };
72 let json = serde_json::to_string(&req).expect("Failed to serialize");
73 assert!(json.contains("appId"));
74 assert!(json.contains("snsId"));
75 assert!(json.contains("open"));
76 }
77}