ncm_api_rs/api/
hug_comment.rs1use super::Query;
2use crate::error::Result;
3use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9 pub async fn hug_comment(&self, query: &Query) -> Result<ApiResponse> {
12 let resource_type = query.get_or("type", "0");
13 let type_prefix = crate::util::config::RESOURCE_TYPE_MAP
14 .get(resource_type.as_str())
15 .copied()
16 .unwrap_or("R_SO_4_");
17 let thread_id = format!("{}{}", type_prefix, query.get_or("sid", "0"));
18 let data = json!({
19 "targetUserId": query.get_or("uid", "0"),
20 "commentId": query.get_or("cid", "0"),
21 "threadId": thread_id
22 });
23 self.request(
24 "/api/v2/resource/comments/hug/listener",
25 data,
26 query.to_option(CryptoType::default()),
27 )
28 .await
29 }
30}