ruma_client_api/tag/
create_tag.rs

1//! `PUT /_matrix/client/*/user/{userId}/rooms/{roomId}/tags/{tag}`
2//!
3//! Add a new tag to a room.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3useruseridroomsroomidtagstag
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedRoomId, OwnedUserId,
13    };
14    use ruma_events::tag::TagInfo;
15
16    const METADATA: Metadata = metadata! {
17        method: PUT,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag",
22            1.1 => "/_matrix/client/v3/user/:user_id/rooms/:room_id/tags/:tag",
23        }
24    };
25
26    /// Request type for the `create_tag` endpoint.
27    #[request(error = crate::Error)]
28    pub struct Request {
29        /// The ID of the user creating the tag.
30        #[ruma_api(path)]
31        pub user_id: OwnedUserId,
32
33        /// The room to tag.
34        #[ruma_api(path)]
35        pub room_id: OwnedRoomId,
36
37        /// The name of the tag to create.
38        #[ruma_api(path)]
39        pub tag: String,
40
41        /// Info about the tag.
42        #[ruma_api(body)]
43        pub tag_info: TagInfo,
44    }
45
46    /// Response type for the `create_tag` endpoint.
47    #[response(error = crate::Error)]
48    #[derive(Default)]
49    pub struct Response {}
50
51    impl Request {
52        /// Creates a new `Request` with the given user ID, room ID, tag and tag info.
53        pub fn new(
54            user_id: OwnedUserId,
55            room_id: OwnedRoomId,
56            tag: String,
57            tag_info: TagInfo,
58        ) -> Self {
59            Self { user_id, room_id, tag, tag_info }
60        }
61    }
62
63    impl Response {
64        /// Creates an empty `Response`.
65        pub fn new() -> Self {
66            Self {}
67        }
68    }
69}