1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
mod response;
use response::{CommentRoot, CommentsRoot};
use crate::{
utils::{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)
}
}