ruma_client_api/profile/
set_display_name.rs

1//! `PUT /_matrix/client/*/profile/{userId}/displayname`
2//!
3//! Set the display name of the user.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/v1.15/client-server-api/#put_matrixclientv3profileuseriddisplayname
9
10    use ruma_common::{
11        OwnedUserId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: PUT,
18        rate_limited: true,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/profile/{user_id}/displayname",
22            1.1 => "/_matrix/client/v3/profile/{user_id}/displayname",
23        }
24    }
25
26    /// Request type for the `set_display_name` endpoint.
27    #[request(error = crate::Error)]
28    pub struct Request {
29        /// The user whose display name will be set.
30        #[ruma_api(path)]
31        pub user_id: OwnedUserId,
32
33        /// The new display name for the user.
34        #[serde(skip_serializing_if = "Option::is_none")]
35        pub displayname: Option<String>,
36    }
37
38    /// Response type for the `set_display_name` endpoint.
39    #[response(error = crate::Error)]
40    #[derive(Default)]
41    pub struct Response {}
42
43    impl Request {
44        /// Creates a new `Request` with the given user ID and display name.
45        #[deprecated = "Use the set_profile_field endpoint instead."]
46        pub fn new(user_id: OwnedUserId, displayname: Option<String>) -> Self {
47            Self { user_id, displayname }
48        }
49    }
50
51    impl Response {
52        /// Creates an empty `Response`.
53        pub fn new() -> Self {
54            Self {}
55        }
56    }
57}