gewe_http/moments/
interact.rs1use crate::client::GeweHttpClient;
2use gewe_core::{CommentSnsRequest, GeweError, LikeSnsRequest};
3use tracing::instrument;
4
5impl GeweHttpClient {
6 #[instrument(skip(self))]
7 pub async fn like_sns(&self, req: LikeSnsRequest<'_>) -> Result<(), GeweError> {
8 let _ = self
9 .post_api::<_, ()>("gewe/v2/api/sns/likeSns", &req)
10 .await?;
11 Ok(())
12 }
13
14 #[instrument(skip(self))]
15 pub async fn comment_sns(&self, req: CommentSnsRequest<'_>) -> Result<(), GeweError> {
16 let _ = self
17 .post_api::<_, ()>("gewe/v2/api/sns/commentSns", &req)
18 .await?;
19 Ok(())
20 }
21}
22
23#[cfg(test)]
24mod tests {
25 use super::*;
26
27 #[test]
28 fn test_like_sns_request() {
29 let req = LikeSnsRequest {
30 app_id: "test_app",
31 sns_id: 123456,
32 oper_type: 1,
33 wxid: "wxid_test",
34 };
35 let json = serde_json::to_string(&req).expect("Failed to serialize");
36 assert!(json.contains("appId"));
37 assert!(json.contains("snsId"));
38 assert!(json.contains("operType"));
39 }
40
41 #[test]
42 fn test_comment_sns_request() {
43 let req = CommentSnsRequest {
44 app_id: "test_app",
45 sns_id: 123456,
46 oper_type: 1,
47 wxid: "wxid_test",
48 comment_id: Some("comment_123"),
49 content: Some("Great post!"),
50 };
51 let json = serde_json::to_string(&req).expect("Failed to serialize");
52 assert!(json.contains("appId"));
53 assert!(json.contains("snsId"));
54 assert!(json.contains("Great post!"));
55 }
56}