misskey_api/endpoint/channels/
followed.rs1use crate::model::channel::Channel;
2#[cfg(feature = "12-48-0")]
3use crate::model::id::Id;
4
5use serde::Serialize;
6use typed_builder::TypedBuilder;
7
8#[derive(Serialize, Default, Debug, Clone, TypedBuilder)]
9#[serde(rename_all = "camelCase")]
10#[builder(doc)]
11pub struct Request {
12 #[cfg(feature = "12-48-0")]
14 #[cfg_attr(docsrs, doc(cfg(feature = "12-48-0")))]
15 #[serde(skip_serializing_if = "Option::is_none")]
16 #[builder(default, setter(strip_option))]
17 pub limit: Option<u8>,
18 #[cfg(feature = "12-48-0")]
19 #[cfg_attr(docsrs, doc(cfg(feature = "12-48-0")))]
20 #[serde(skip_serializing_if = "Option::is_none")]
21 #[builder(default, setter(strip_option))]
22 pub until_id: Option<Id<Channel>>,
23 #[cfg(feature = "12-48-0")]
24 #[cfg_attr(docsrs, doc(cfg(feature = "12-48-0")))]
25 #[serde(skip_serializing_if = "Option::is_none")]
26 #[builder(default, setter(strip_option))]
27 pub since_id: Option<Id<Channel>>,
28}
29
30impl misskey_core::Request for Request {
31 type Response = Vec<Channel>;
32 const ENDPOINT: &'static str = "channels/followed";
33}
34
35#[cfg(feature = "12-48-0")]
36impl_pagination!(Request, Channel);
37
38#[cfg(test)]
39mod tests {
40 use super::Request;
41 use crate::test::{ClientExt, TestClient};
42
43 #[tokio::test]
44 async fn request() {
45 let client = TestClient::new();
46 client.test(Request::default()).await;
47 }
48
49 #[cfg(feature = "12-48-0")]
50 #[tokio::test]
51 async fn request_with_limit() {
52 let client = TestClient::new();
53 client
54 .test(Request {
55 limit: Some(10),
56 until_id: None,
57 since_id: None,
58 })
59 .await;
60 }
61
62 #[cfg(feature = "12-48-0")]
63 #[tokio::test]
64 async fn request_paginate() {
65 let client = TestClient::new();
66 let channel = client
67 .test(crate::endpoint::channels::create::Request {
68 name: "test channel".to_string(),
69 description: None,
70 banner_id: None,
71 })
72 .await;
73 client
74 .test(crate::endpoint::channels::follow::Request {
75 channel_id: channel.id.clone(),
76 })
77 .await;
78
79 client
80 .test(Request {
81 limit: None,
82 until_id: Some(channel.id.clone()),
83 since_id: Some(channel.id.clone()),
84 })
85 .await;
86 }
87}