ruma_client_api/voip/get_turn_server_info.rs
1//! `GET /_matrix/client/*/voip/turnServer`
2//!
3//! Get credentials for the client to use when initiating VoIP calls.
4
5pub mod v3 {
6 //! `/v3/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/v1.18/client-server-api/#get_matrixclientv3voipturnserver
9
10 use std::time::Duration;
11
12 use ruma_common::{
13 api::{auth_scheme::AccessToken, request, response},
14 metadata,
15 };
16
17 metadata! {
18 method: GET,
19 rate_limited: true,
20 authentication: AccessToken,
21 history: {
22 1.0 => "/_matrix/client/r0/voip/turnServer",
23 1.1 => "/_matrix/client/v3/voip/turnServer",
24 }
25 }
26
27 /// Request type for the `turn_server_info` endpoint.
28 #[request]
29 #[derive(Default)]
30 pub struct Request {}
31
32 /// Response type for the `turn_server_info` endpoint.
33 #[response]
34 pub struct Response {
35 /// The username to use.
36 pub username: String,
37
38 /// The password to use.
39 pub password: String,
40
41 /// A list of TURN URIs.
42 pub uris: Vec<String>,
43
44 /// The time-to-live in seconds.
45 #[serde(with = "ruma_common::serde::duration::secs")]
46 pub ttl: Duration,
47 }
48
49 impl Request {
50 /// Creates an empty `Request`.
51 pub fn new() -> Self {
52 Self {}
53 }
54 }
55
56 impl Response {
57 /// Creates a new `Response` with the given username, password, TURN URIs and time-to-live.
58 pub fn new(username: String, password: String, uris: Vec<String>, ttl: Duration) -> Self {
59 Self { username, password, uris, ttl }
60 }
61 }
62}