ruma_identity_service_api/association/check_3pid_validity.rs
1//! `GET /_matrix/identity/*/3pid/getValidated3pid`
2//!
3//! Determine if a given 3PID has been validated by a user.
4
5pub mod v2 {
6 //! `/v2/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/v1.19/identity-service-api/#get_matrixidentityv23pidgetvalidated3pid
9
10 use js_int::UInt;
11 use ruma_common::{
12 OwnedClientSecret, OwnedSessionId,
13 api::{request, response},
14 metadata,
15 thirdparty::Medium,
16 };
17
18 use crate::IdentityServiceToken;
19
20 metadata! {
21 method: GET,
22 rate_limited: false,
23 authentication: IdentityServiceToken,
24 history: {
25 1.0 => "/_matrix/identity/v2/3pid/getValidated3pid/",
26 }
27 }
28
29 /// Request type for the `check_3pid_validity` endpoint.
30 #[request]
31 pub struct Request {
32 /// The Session ID generated by the `requestToken` call.
33 #[ruma_api(query)]
34 pub sid: OwnedSessionId,
35
36 /// The client secret passed to the `requestToken` call.
37 #[ruma_api(query)]
38 pub client_secret: OwnedClientSecret,
39 }
40
41 /// Response type for the `check_3pid_validity` endpoint.
42 #[response]
43 pub struct Response {
44 /// The medium type of the 3PID.
45 pub medium: Medium,
46
47 /// The address of the 3PID being looked up.
48 pub address: String,
49
50 /// Timestamp, in milliseconds, indicating the time that the 3PID was validated.
51 pub validated_at: UInt,
52 }
53
54 impl Request {
55 /// Creates a `Request` with the given Session ID and client secret.
56 pub fn new(sid: OwnedSessionId, client_secret: OwnedClientSecret) -> Self {
57 Self { sid, client_secret }
58 }
59 }
60
61 impl Response {
62 /// Creates a `Response` with the given medium, address and validation timestamp.
63 pub fn new(medium: Medium, address: String, validated_at: UInt) -> Self {
64 Self { medium, address, validated_at }
65 }
66 }
67}