misskey_api/endpoint/charts/
network.rs

1use crate::model::chart::{ChartSpan, NetworkChart};
2
3use serde::Serialize;
4use typed_builder::TypedBuilder;
5
6#[derive(Serialize, Debug, Clone, TypedBuilder)]
7#[serde(rename_all = "camelCase")]
8#[builder(doc)]
9pub struct Request {
10    pub span: ChartSpan,
11    /// 1 .. 500
12    #[serde(skip_serializing_if = "Option::is_none")]
13    #[builder(default, setter(strip_option))]
14    pub limit: Option<u64>,
15    #[builder(default, setter(strip_option))]
16    pub offset: Option<u64>,
17}
18
19impl misskey_core::Request for Request {
20    type Response = NetworkChart;
21    const ENDPOINT: &'static str = "charts/network";
22}
23
24#[cfg(test)]
25mod tests {
26    use super::Request;
27    use crate::test::{ClientExt, TestClient};
28
29    #[tokio::test]
30    async fn request() {
31        use crate::model::chart::ChartSpan;
32
33        let client = TestClient::new();
34        client
35            .test(Request {
36                span: ChartSpan::Day,
37                limit: None,
38                offset: None,
39            })
40            .await;
41        client
42            .test(Request {
43                span: ChartSpan::Hour,
44                limit: None,
45                offset: None,
46            })
47            .await;
48    }
49
50    #[tokio::test]
51    async fn request_with_limit() {
52        use crate::model::chart::ChartSpan;
53
54        let client = TestClient::new();
55        client
56            .test(Request {
57                span: ChartSpan::Day,
58                limit: Some(500),
59                offset: None,
60            })
61            .await;
62    }
63
64    #[tokio::test]
65    async fn request_with_offset() {
66        use crate::model::chart::ChartSpan;
67
68        let client = TestClient::new();
69        client
70            .test(Request {
71                span: ChartSpan::Day,
72                limit: None,
73                offset: Some(5),
74            })
75            .await;
76    }
77}