diff --git a/ruma-client-api/src/r0/thirdparty/get_location_for_protocol.rs b/ruma-client-api/src/r0/thirdparty/get_location_for_protocol.rs index d5356a02..22bfb23f 100644 --- a/ruma-client-api/src/r0/thirdparty/get_location_for_protocol.rs +++ b/ruma-client-api/src/r0/thirdparty/get_location_for_protocol.rs @@ -15,10 +15,11 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The protocol used to communicate to the third party network. #[ruma_api(path)] - pub protocol: String, + pub protocol: &'a str, /// One or more custom fields to help identify the third party location. // The specification is incorrect for this parameter. See matrix-org/matrix-doc#2352. @@ -26,6 +27,7 @@ ruma_api! { pub fields: BTreeMap, } + #[non_exhaustive] response: { /// List of matched third party locations. #[ruma_api(body)] @@ -34,3 +36,17 @@ ruma_api! { error: crate::Error } + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given protocol. + pub fn new(protocol: &'a str) -> Self { + Self { protocol, fields: BTreeMap::new() } + } +} + +impl Response { + /// Creates a new `Response` with the given locations. + pub fn new(locations: Vec) -> Self { + Self { locations } + } +} diff --git a/ruma-client-api/src/r0/thirdparty/get_location_for_room_alias.rs b/ruma-client-api/src/r0/thirdparty/get_location_for_room_alias.rs index 7ec7d1a1..50b4763c 100644 --- a/ruma-client-api/src/r0/thirdparty/get_location_for_room_alias.rs +++ b/ruma-client-api/src/r0/thirdparty/get_location_for_room_alias.rs @@ -14,12 +14,14 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The Matrix room alias to look up. #[ruma_api(query)] - pub alias: RoomAliasId, + pub alias: &'a RoomAliasId, } + #[non_exhaustive] response: { /// List of matched third party locations. #[ruma_api(body)] @@ -28,3 +30,17 @@ ruma_api! { error: crate::Error } + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given room alias ID. + pub fn new(alias: &'a RoomAliasId) -> Self { + Self { alias } + } +} + +impl Response { + /// Creates a new `Reponse` with the given locations. + pub fn new(locations: Vec) -> Self { + Self { locations } + } +} diff --git a/ruma-client-api/src/r0/thirdparty/get_protocol.rs b/ruma-client-api/src/r0/thirdparty/get_protocol.rs index 5d759d6b..11feb3f4 100644 --- a/ruma-client-api/src/r0/thirdparty/get_protocol.rs +++ b/ruma-client-api/src/r0/thirdparty/get_protocol.rs @@ -13,12 +13,14 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The name of the protocol. #[ruma_api(path)] - pub protocol: String, + pub protocol: &'a str, } + #[non_exhaustive] response: { /// Metadata about the protocol. #[ruma_api(body)] @@ -27,3 +29,17 @@ ruma_api! { error: crate::Error } + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given protocol name. + pub fn new(protocol: &'a str) -> Self { + Self { protocol } + } +} + +impl Response { + /// Creates a new `Response` with the given procotol. + pub fn new(protocol: Protocol) -> Self { + Self { protocol } + } +} diff --git a/ruma-client-api/src/r0/thirdparty/get_protocols.rs b/ruma-client-api/src/r0/thirdparty/get_protocols.rs index d7764aae..3b70264c 100644 --- a/ruma-client-api/src/r0/thirdparty/get_protocols.rs +++ b/ruma-client-api/src/r0/thirdparty/get_protocols.rs @@ -15,8 +15,11 @@ ruma_api! { requires_authentication: true, } + #[derive(Default)] + #[non_exhaustive] request: {} + #[non_exhaustive] response: { /// Metadata about protocols supported by the homeserver. #[ruma_api(body)] @@ -25,3 +28,17 @@ ruma_api! { error: crate::Error } + +impl Request { + /// Creates an empty `Request`. + pub fn new() -> Self { + Self + } +} + +impl Response { + /// Creates a new `Response` with the given procotols. + pub fn new(protocols: BTreeMap) -> Self { + Self { protocols } + } +} diff --git a/ruma-client-api/src/r0/thirdparty/get_user_for_protocol.rs b/ruma-client-api/src/r0/thirdparty/get_user_for_protocol.rs index 123828b7..dbb33544 100644 --- a/ruma-client-api/src/r0/thirdparty/get_user_for_protocol.rs +++ b/ruma-client-api/src/r0/thirdparty/get_user_for_protocol.rs @@ -15,10 +15,11 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The protocol used to communicate to the third party network. #[ruma_api(path)] - pub protocol: String, + pub protocol: &'a str, /// One or more custom fields that are passed to the AS to help identify the user. // The specification is incorrect for this parameter. See matrix-org/matrix-doc#2352. @@ -26,6 +27,7 @@ ruma_api! { pub fields: BTreeMap, } + #[non_exhaustive] response: { /// List of matched third party users. #[ruma_api(body)] @@ -34,3 +36,17 @@ ruma_api! { error: crate::Error } + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given protocol. + pub fn new(protocol: &'a str) -> Self { + Self { protocol, fields: BTreeMap::new() } + } +} + +impl Response { + /// Creates a new `Response` with the given users. + pub fn new(users: Vec) -> Self { + Self { users } + } +} diff --git a/ruma-client-api/src/r0/thirdparty/get_user_for_user_id.rs b/ruma-client-api/src/r0/thirdparty/get_user_for_user_id.rs index fe1e4b88..91440774 100644 --- a/ruma-client-api/src/r0/thirdparty/get_user_for_user_id.rs +++ b/ruma-client-api/src/r0/thirdparty/get_user_for_user_id.rs @@ -14,12 +14,14 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The Matrix User ID to look up. #[ruma_api(query)] - pub userid: UserId, + pub userid: &'a UserId, } + #[non_exhaustive] response: { /// List of matched third party users. #[ruma_api(body)] @@ -28,3 +30,17 @@ ruma_api! { error: crate::Error } + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given user ID. + pub fn new(userid: &'a UserId) -> Self { + Self { userid } + } +} + +impl Response { + /// Creates a new `Response` with the given users. + pub fn new(users: Vec) -> Self { + Self { users } + } +}