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