ruma_client_api/device/
update_device.rs

1//! `PUT /_matrix/client/*/devices/{deviceId}`
2//!
3//! Update metadata for a device.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3devicesdeviceid
9
10    use ruma_common::{
11        OwnedDeviceId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: PUT,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/devices/{device_id}",
22            1.1 => "/_matrix/client/v3/devices/{device_id}",
23        }
24    }
25
26    /// Request type for the `update_device` endpoint.
27    #[request(error = crate::Error)]
28    pub struct Request {
29        /// The device to update.
30        #[ruma_api(path)]
31        pub device_id: OwnedDeviceId,
32
33        /// The new display name for this device.
34        ///
35        /// If this is `None`, the display name won't be changed.
36        #[serde(skip_serializing_if = "Option::is_none")]
37        pub display_name: Option<String>,
38    }
39
40    /// Response type for the `update_device` endpoint.
41    #[response(error = crate::Error)]
42    #[derive(Default)]
43    pub struct Response {}
44
45    impl Request {
46        /// Creates a new `Request` with the given device ID.
47        pub fn new(device_id: OwnedDeviceId) -> Self {
48            Self { device_id, display_name: None }
49        }
50    }
51
52    impl Response {
53        /// Creates an empty `Response`.
54        pub fn new() -> Self {
55            Self {}
56        }
57    }
58}