use openlark_core::{
SDKResult, api::ApiRequest, config::Config, http::Transport, req_option::RequestOption,
validate_required,
};
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct FileCommentReplyCreateRequest {
config: Arc<Config>,
file_token: String,
comment_id: String,
}
impl FileCommentReplyCreateRequest {
pub fn new(config: Arc<Config>) -> Self {
Self {
config,
file_token: String::new(),
comment_id: String::new(),
}
}
pub fn file_token(mut self, file_token: impl Into<String>) -> Self {
self.file_token = file_token.into();
self
}
pub fn comment_id(mut self, comment_id: impl Into<String>) -> Self {
self.comment_id = comment_id.into();
self
}
pub async fn execute(self, body: serde_json::Value) -> SDKResult<serde_json::Value> {
self.execute_with_options(body, RequestOption::default())
.await
}
pub async fn execute_with_options(
self,
body: serde_json::Value,
option: RequestOption,
) -> SDKResult<serde_json::Value> {
validate_required!(self.file_token, "file_token 不能为空");
validate_required!(self.comment_id, "comment_id 不能为空");
let path = format!(
"/open-apis/drive/v1/files/{}/comments/{}/replies",
self.file_token, self.comment_id
);
let req: ApiRequest<serde_json::Value> = ApiRequest::post(path).body(body);
let resp = Transport::request(req, &self.config, Some(option)).await?;
resp.data
.ok_or_else(|| openlark_core::error::validation_error("添加回复", "响应数据为空"))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn builder_initializes() {
let config = Arc::new(Config::default());
let _request = FileCommentReplyCreateRequest::new(config);
}
}