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