ruma_client_api/device/get_devices.rs
1//! `GET /_matrix/client/*/devices`
2//!
3//! Get registered devices for authenticated user.
4
5pub mod v3 {
6 //! `/v3/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3devices
9
10 use ruma_common::{
11 api::{request, response},
12 metadata,
13 };
14
15 use crate::device::Device;
16
17 metadata! {
18 method: GET,
19 rate_limited: false,
20 authentication: AccessToken,
21 history: {
22 1.0 => "/_matrix/client/r0/devices",
23 1.1 => "/_matrix/client/v3/devices",
24 }
25 }
26
27 /// Request type for the `get_devices` endpoint.
28 #[request(error = crate::Error)]
29 #[derive(Default)]
30 pub struct Request {}
31
32 /// Response type for the `get_devices` endpoint.
33 #[response(error = crate::Error)]
34 pub struct Response {
35 /// A list of all registered devices for this user
36 pub devices: Vec<Device>,
37 }
38
39 impl Request {
40 /// Creates an empty `Request`.
41 pub fn new() -> Self {
42 Self {}
43 }
44 }
45
46 impl Response {
47 /// Creates a new `Response` with the given devices.
48 pub fn new(devices: Vec<Device>) -> Self {
49 Self { devices }
50 }
51 }
52}