ruma_appservice_api/thirdparty/get_user_for_protocol.rs
1//! `GET /_matrix/app/*/thirdparty/user/{protocol}`
2//!
3//! Retrieve a Matrix User ID linked to a user on the third party network, given a set of user
4//! parameters.
5
6pub mod v1 {
7 //! `/v1/` ([spec])
8 //!
9 //! [spec]: https://spec.matrix.org/latest/application-service-api/#get_matrixappv1thirdpartyuserprotocol
10
11 use std::collections::BTreeMap;
12
13 use ruma_common::{
14 api::{auth_scheme::AccessToken, request, response},
15 metadata,
16 thirdparty::User,
17 };
18
19 metadata! {
20 method: GET,
21 rate_limited: false,
22 authentication: AccessToken,
23 path: "/_matrix/app/v1/thirdparty/user/{protocol}",
24 }
25
26 /// Request type for the `get_user_for_protocol` endpoint.
27 #[request]
28 pub struct Request {
29 /// The protocol used to communicate to the third party network.
30 #[ruma_api(path)]
31 pub protocol: String,
32
33 /// One or more custom fields that are passed to the AS to help identify the user.
34 #[ruma_api(query_all)]
35 pub fields: BTreeMap<String, String>,
36 }
37
38 /// Response type for the `get_user_for_protocol` endpoint.
39 #[response]
40 pub struct Response {
41 /// List of matched third party users.
42 #[ruma_api(body)]
43 pub users: Vec<User>,
44 }
45
46 impl Request {
47 /// Creates a new `Request` with the given protocol name.
48 pub fn new(protocol: String) -> Self {
49 Self { protocol, fields: BTreeMap::new() }
50 }
51 }
52
53 impl Response {
54 /// Creates a new `Response` with the given users.
55 pub fn new(users: Vec<User>) -> Self {
56 Self { users }
57 }
58 }
59}