ruma_identity_service_api/association/msisdn/
validate_msisdn.rs

1//! `POST /_matrix/identity/*/validate/msisdn/submitToken`
2//!
3//! Validate the ownership of a phone number.
4
5pub mod v2 {
6    //! `/v2/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/identity-service-api/#post_matrixidentityv2validatemsisdnsubmittoken
9
10    use ruma_common::{
11        OwnedClientSecret, OwnedSessionId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: POST,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/identity/v2/validate/msisdn/submitToken",
22        }
23    }
24
25    /// Request type for the `validate_msisdn` endpoint.
26    #[request]
27    pub struct Request {
28        /// The session ID, generated by the `requestToken` call.
29        pub sid: OwnedSessionId,
30
31        /// The client secret that was supplied to the `requestToken` call.
32        pub client_secret: OwnedClientSecret,
33
34        /// The token generated by the `requestToken` call and sent to the user.
35        pub token: String,
36    }
37
38    /// Response type for the `validate_msisdn` endpoint.
39    #[response]
40    pub struct Response {
41        /// Whether the validation was successful or not.
42        pub success: bool,
43    }
44
45    impl Request {
46        /// Create a new `Request` with the given session ID, client secret and token.
47        pub fn new(sid: OwnedSessionId, client_secret: OwnedClientSecret, token: String) -> Self {
48            Self { sid, client_secret, token }
49        }
50    }
51
52    impl Response {
53        /// Create a new `Response` with the success status.
54        pub fn new(success: bool) -> Self {
55            Self { success }
56        }
57    }
58}