ruma_client_api/account/bind_3pid.rs
1//! `POST /_matrix/client/*/account/3pid/bind`
2//!
3//! Bind a 3PID to a user's account on an identity server
4
5pub mod v3 {
6 //! `/v3/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3account3pidbind
9
10 use ruma_common::{
11 OwnedClientSecret, OwnedSessionId,
12 api::{auth_scheme::AccessToken, request, response},
13 metadata,
14 };
15
16 use crate::account::IdentityServerInfo;
17
18 metadata! {
19 method: POST,
20 rate_limited: true,
21 authentication: AccessToken,
22 history: {
23 1.0 => "/_matrix/client/r0/account/3pid/bind",
24 1.1 => "/_matrix/client/v3/account/3pid/bind",
25 }
26 }
27
28 /// Request type for the `bind_3pid` endpoint.
29 #[request(error = crate::Error)]
30 pub struct Request {
31 /// Client-generated secret string used to protect this session.
32 pub client_secret: OwnedClientSecret,
33
34 /// The ID server to send the onward request to as a hostname with an
35 /// appended colon and port number if the port is not the default.
36 #[serde(flatten)]
37 pub identity_server_info: IdentityServerInfo,
38
39 /// The session identifier given by the identity server.
40 pub sid: OwnedSessionId,
41 }
42
43 /// Response type for the `bind_3pid` endpoint.
44 #[response(error = crate::Error)]
45 #[derive(Default)]
46 pub struct Response {}
47
48 impl Request {
49 /// Creates a new `Request` with the given client secret, identity server information and
50 /// session identifier.
51 pub fn new(
52 client_secret: OwnedClientSecret,
53 identity_server_info: IdentityServerInfo,
54 sid: OwnedSessionId,
55 ) -> Self {
56 Self { client_secret, identity_server_info, sid }
57 }
58 }
59
60 impl Response {
61 /// Creates an empty `Response`.
62 pub fn new() -> Self {
63 Self {}
64 }
65 }
66}