misskey_api/endpoint/clips/
notes.rs1use crate::model::{clip::Clip, 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 clip_id: Id<Clip>,
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 = "clips/notes";
26}
27
28impl_pagination!(Request, Note);
29
30#[cfg(feature = "12-57-0")]
31#[cfg(test)]
32mod tests {
33 use super::Request;
34 use crate::test::{ClientExt, TestClient};
35
36 #[tokio::test]
37 async fn request_simple() {
38 let client = TestClient::new();
39 let clip = client
40 .user
41 .test(crate::endpoint::clips::create::Request {
42 name: "testclip".to_string(),
43 is_public: None,
44 description: None,
45 })
46 .await;
47 client
48 .test(Request {
49 clip_id: clip.id,
50 limit: None,
51 since_id: None,
52 until_id: None,
53 })
54 .await;
55 }
56
57 #[tokio::test]
58 async fn request_with_limit() {
59 let client = TestClient::new();
60 let clip = client
61 .user
62 .test(crate::endpoint::clips::create::Request {
63 name: "testclip".to_string(),
64 is_public: None,
65 description: None,
66 })
67 .await;
68 let note = client.user.create_note(Some("test"), None, None).await;
69
70 client
71 .test(crate::endpoint::clips::add_note::Request {
72 clip_id: clip.id,
73 note_id: note.id,
74 })
75 .await;
76
77 client
78 .test(Request {
79 clip_id: clip.id,
80 limit: Some(100),
81 since_id: None,
82 until_id: None,
83 })
84 .await;
85 }
86
87 #[tokio::test]
88 async fn request_paginate() {
89 let client = TestClient::new();
90 let clip = client
91 .user
92 .test(crate::endpoint::clips::create::Request {
93 name: "testclip".to_string(),
94 is_public: None,
95 description: None,
96 })
97 .await;
98 let note = client.user.create_note(Some("test"), None, None).await;
99
100 client
101 .test(crate::endpoint::clips::add_note::Request {
102 clip_id: clip.id,
103 note_id: note.id,
104 })
105 .await;
106
107 client
108 .test(Request {
109 clip_id: clip.id,
110 limit: None,
111 since_id: Some(note.id),
112 until_id: Some(note.id),
113 })
114 .await;
115 }
116}