Expand description
评论 API 模块
这个模块提供了与评论相关的 API 操作,包括发布评论、更新评论、点赞评论、感谢评论、删除评论等功能。
主要结构体是 Comment,用于管理评论的 API 请求。
§主要组件
Comment- 评论客户端结构体,负责所有评论相关的 API 调用。
§方法列表
Comment::new- 创建新的评论客户端实例。Comment::send- 发布评论。Comment::update- 更新评论。Comment::vote- 评论点赞。Comment::thank- 评论感谢。Comment::remove- 删除评论。
§示例
use fishpi_sdk::api::comment::Comment;
use fishpi_sdk::model::article::CommentPost;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let comment = Comment::new("your_api_key".to_string());
// 发布评论
let data = CommentPost {
articleId: "article_id".to_string(),
isAnonymous: false,
isVisible: true,
content: "This is a comment.".to_string(),
replyId: "".to_string(),
};
let result = comment.send(&data).await?;
println!("Sent: {}", result.success);
// 更新评论
let updated_content = comment.update("comment_id", &data).await?;
println!("Updated content: {}", updated_content);
// 点赞评论
let voted = comment.vote("comment_id", true).await?;
println!("Voted: {}", voted);
Ok(())
}