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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use crate::model::chart::{ChartSpan, NetworkChart};
use serde::Serialize;
use typed_builder::TypedBuilder;
#[derive(Serialize, Debug, Clone, TypedBuilder)]
#[serde(rename_all = "camelCase")]
#[builder(doc)]
pub struct Request {
pub span: ChartSpan,
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub limit: Option<u64>,
#[builder(default, setter(strip_option))]
pub offset: Option<u64>,
}
impl misskey_core::Request for Request {
type Response = NetworkChart;
const ENDPOINT: &'static str = "charts/network";
}
#[cfg(test)]
mod tests {
use super::Request;
use crate::test::{ClientExt, TestClient};
#[tokio::test]
async fn request() {
use crate::model::chart::ChartSpan;
let client = TestClient::new();
client
.test(Request {
span: ChartSpan::Day,
limit: None,
offset: None,
})
.await;
client
.test(Request {
span: ChartSpan::Hour,
limit: None,
offset: None,
})
.await;
}
#[tokio::test]
async fn request_with_limit() {
use crate::model::chart::ChartSpan;
let client = TestClient::new();
client
.test(Request {
span: ChartSpan::Day,
limit: Some(500),
offset: None,
})
.await;
}
#[tokio::test]
async fn request_with_offset() {
use crate::model::chart::ChartSpan;
let client = TestClient::new();
client
.test(Request {
span: ChartSpan::Day,
limit: None,
offset: Some(5),
})
.await;
}
}