ruma_client_api/account/
unbind_3pid.rs

1//! `POST /_matrix/client/*/account/3pid/unbind`
2//!
3//! Unbind a 3PID from 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_matrixclientv3account3pidunbind
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata,
13        thirdparty::Medium,
14    };
15
16    use crate::account::ThirdPartyIdRemovalStatus;
17
18    const METADATA: Metadata = metadata! {
19        method: POST,
20        rate_limited: false,
21        authentication: AccessToken,
22        history: {
23            1.0 => "/_matrix/client/r0/account/3pid/unbind",
24            1.1 => "/_matrix/client/v3/account/3pid/unbind",
25        }
26    };
27
28    /// Request type for the `unbind_3pid` endpoint.
29    #[request(error = crate::Error)]
30    pub struct Request {
31        /// Identity server to unbind from.
32        #[serde(skip_serializing_if = "Option::is_none")]
33        pub id_server: Option<String>,
34
35        /// Medium of the 3PID to be removed.
36        pub medium: Medium,
37
38        /// Third-party address being removed.
39        pub address: String,
40    }
41
42    /// Response type for the `unbind_3pid` endpoint.
43    #[response(error = crate::Error)]
44    pub struct Response {
45        /// Result of unbind operation.
46        pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
47    }
48
49    impl Request {
50        /// Creates a new `Request` with the given medium and third-party address.
51        pub fn new(medium: Medium, address: String) -> Self {
52            Self { id_server: None, medium, address }
53        }
54    }
55
56    impl Response {
57        /// Creates a new `Response` with the given unbind result.
58        pub fn new(id_server_unbind_result: ThirdPartyIdRemovalStatus) -> Self {
59            Self { id_server_unbind_result }
60        }
61    }
62}