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