ruma_client_api/account/
get_3pids.rs

1//! `GET /_matrix/client/*/account/3pid`
2//!
3//! Get a list of 3rd party contacts associated with the user's account.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3account3pid
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata,
13        thirdparty::ThirdPartyIdentifier,
14    };
15
16    const METADATA: Metadata = metadata! {
17        method: GET,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/account/3pid",
22            1.1 => "/_matrix/client/v3/account/3pid",
23        }
24    };
25
26    /// Request type for the `get_3pids` endpoint.
27    #[request(error = crate::Error)]
28    #[derive(Default)]
29    pub struct Request {}
30
31    /// Response type for the `get_3pids` endpoint.
32    #[response(error = crate::Error)]
33    pub struct Response {
34        /// A list of third party identifiers the homeserver has associated with the user's
35        /// account.
36        ///
37        /// If the `compat-get-3pids` feature is enabled, this field will always be serialized,
38        /// even if its value is an empty list.
39        #[serde(default)]
40        #[cfg_attr(
41            not(feature = "compat-get-3pids"),
42            serde(skip_serializing_if = "Vec::is_empty")
43        )]
44        pub threepids: Vec<ThirdPartyIdentifier>,
45    }
46
47    impl Request {
48        /// Creates an empty `Request`.
49        pub fn new() -> Self {
50            Self {}
51        }
52    }
53
54    impl Response {
55        /// Creates a new `Response` with the given third party identifiers.
56        pub fn new(threepids: Vec<ThirdPartyIdentifier>) -> Self {
57            Self { threepids }
58        }
59    }
60}