misskey_api/endpoint/notes/
conversation.rs

1use crate::model::{id::Id, note::Note};
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 note_id: Id<Note>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    #[builder(default, setter(strip_option))]
13    pub offset: Option<u64>,
14    /// 1 .. 100
15    #[serde(skip_serializing_if = "Option::is_none")]
16    #[builder(default, setter(strip_option))]
17    pub limit: Option<u8>,
18}
19
20impl misskey_core::Request for Request {
21    type Response = Vec<Note>;
22    const ENDPOINT: &'static str = "notes/conversation";
23}
24
25impl_offset_pagination!(Request, Note);
26
27#[cfg(test)]
28mod tests {
29    use super::Request;
30    use crate::test::{ClientExt, TestClient};
31
32    #[tokio::test]
33    async fn request() {
34        let client = TestClient::new();
35        let note = client.create_note(Some("test"), None, None).await;
36        client
37            .test(Request {
38                note_id: note.id,
39                offset: None,
40                limit: None,
41            })
42            .await;
43    }
44
45    #[tokio::test]
46    async fn request_with_limit() {
47        let client = TestClient::new();
48        let note = client.create_note(Some("test"), None, None).await;
49        client
50            .test(Request {
51                note_id: note.id,
52                limit: Some(100),
53                offset: None,
54            })
55            .await;
56    }
57
58    #[tokio::test]
59    async fn request_with_offset() {
60        let client = TestClient::new();
61        let note = client.create_note(Some("test"), None, None).await;
62        client
63            .test(Request {
64                note_id: note.id,
65                limit: None,
66                offset: Some(5),
67            })
68            .await;
69    }
70}