misskey_api/endpoint/admin/announcements/
update.rs1use crate::model::{announcement::Announcement, id::Id};
2
3use serde::Serialize;
4use typed_builder::TypedBuilder;
5use url::Url;
6
7#[derive(Serialize, Debug, Clone, TypedBuilder)]
8#[serde(rename_all = "camelCase")]
9#[builder(doc)]
10pub struct Request {
11 pub id: Id<Announcement>,
12 #[builder(setter(into))]
13 pub title: String,
14 #[builder(setter(into))]
15 pub text: String,
16 #[builder(default, setter(strip_option))]
17 pub image_url: Option<Url>,
18}
19
20impl misskey_core::Request for Request {
21 type Response = ();
22 const ENDPOINT: &'static str = "admin/announcements/update";
23}
24
25#[cfg(test)]
26mod tests {
27 use super::Request;
28 use crate::test::{ClientExt, TestClient};
29
30 #[tokio::test]
31 async fn request() {
32 let client = TestClient::new();
33 let announcement = client
34 .admin
35 .test(crate::endpoint::admin::announcements::create::Request {
36 title: "hello".to_string(),
37 text: "ok".to_string(),
38 image_url: None,
39 })
40 .await;
41
42 client
43 .admin
44 .test(Request {
45 id: announcement.id,
46 title: "attention".to_string(),
47 text: "hello".to_string(),
48 image_url: None,
49 })
50 .await;
51 }
52
53 #[tokio::test]
54 async fn request_with_image() {
55 let client = TestClient::new();
56 let announcement = client
57 .admin
58 .test(crate::endpoint::admin::announcements::create::Request {
59 title: "hello".to_string(),
60 text: "ok".to_string(),
61 image_url: None,
62 })
63 .await;
64 let image_url = client.avatar_url().await;
65
66 client
67 .admin
68 .test(Request {
69 id: announcement.id,
70 title: "hey".to_string(),
71 text: "ok".to_string(),
72 image_url: Some(image_url),
73 })
74 .await;
75 }
76}