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