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