ruma_client_api/account/
add_3pid.rs

1//! `POST /_matrix/client/*/account/3pid/add`
2//!
3//! Add contact information to a user's account
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3account3pidadd
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedClientSecret, OwnedSessionId,
13    };
14
15    use crate::uiaa::{AuthData, UiaaResponse};
16
17    const METADATA: Metadata = metadata! {
18        method: POST,
19        rate_limited: true,
20        authentication: AccessToken,
21        history: {
22            1.0 => "/_matrix/client/r0/account/3pid/add",
23            1.1 => "/_matrix/client/v3/account/3pid/add",
24        }
25    };
26
27    /// Request type for the `add_3pid` endpoint.
28    #[request(error = UiaaResponse)]
29    pub struct Request {
30        /// Additional information for the User-Interactive Authentication API.
31        #[serde(skip_serializing_if = "Option::is_none")]
32        pub auth: Option<AuthData>,
33
34        /// Client-generated secret string used to protect this session.
35        pub client_secret: OwnedClientSecret,
36
37        /// The session identifier given by the identity server.
38        pub sid: OwnedSessionId,
39    }
40
41    /// Response type for the `add_3pid` endpoint.
42    #[response(error = UiaaResponse)]
43    #[derive(Default)]
44    pub struct Response {}
45
46    impl Request {
47        /// Creates a new `Request` with the given client secret and session identifier.
48        pub fn new(client_secret: OwnedClientSecret, sid: OwnedSessionId) -> Self {
49            Self { auth: None, client_secret, sid }
50        }
51    }
52
53    impl Response {
54        /// Creates an empty `Response`.
55        pub fn new() -> Self {
56            Self {}
57        }
58    }
59}