mod response;
pub use response::{CommentRoot, CommentsRoot};
mod model;
pub use model::{Comment, CommentAttributes, Comments};
use crate::{
utils::{http_delete, http_get, http_get_with_params},
VtClient, VtResult,
};
impl VtClient {
pub fn get_comments(
self,
limit: Option<&str>,
filter: Option<&str>,
cursor: Option<&str>,
) -> VtResult<CommentsRoot> {
let url = format!("{}/comments", self.endpoint);
let mut query_params: Vec<(&str, &str)> = Vec::new();
if let Some(l) = limit {
query_params.push(("limit", l))
}
if let Some(f) = filter {
query_params.push(("filter", f))
}
if let Some(c) = cursor {
query_params.push(("cursor", c))
}
http_get_with_params(
&self.api_key,
&self.user_agent,
&url,
query_params.as_slice(),
)
}
pub fn get_comment(self, comment_id: &str) -> VtResult<CommentRoot> {
let url = format!("{}/comments/{}", self.endpoint, comment_id);
http_get(&self.api_key, &self.user_agent, &url)
}
pub fn delete_comment(self, comment_id: &str) -> VtResult<CommentRoot> {
let url = format!("{}/comments/{}", self.endpoint, comment_id);
http_delete(&self.api_key, &self.user_agent, &url)
}
}