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