client-api: Update thirdparty endpoints to the new API standards

This commit is contained in:
Jonas Platte 2020-08-30 22:33:05 +02:00
parent 5407a95a99
commit 76058b8170
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
6 changed files with 102 additions and 5 deletions

View File

@ -15,10 +15,11 @@ ruma_api! {
requires_authentication: true, requires_authentication: true,
} }
#[non_exhaustive]
request: { request: {
/// The protocol used to communicate to the third party network. /// The protocol used to communicate to the third party network.
#[ruma_api(path)] #[ruma_api(path)]
pub protocol: String, pub protocol: &'a str,
/// One or more custom fields to help identify the third party location. /// 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. // The specification is incorrect for this parameter. See matrix-org/matrix-doc#2352.
@ -26,6 +27,7 @@ ruma_api! {
pub fields: BTreeMap<String, String>, pub fields: BTreeMap<String, String>,
} }
#[non_exhaustive]
response: { response: {
/// List of matched third party locations. /// List of matched third party locations.
#[ruma_api(body)] #[ruma_api(body)]
@ -34,3 +36,17 @@ ruma_api! {
error: crate::Error 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<Location>) -> Self {
Self { locations }
}
}

View File

@ -14,12 +14,14 @@ ruma_api! {
requires_authentication: true, requires_authentication: true,
} }
#[non_exhaustive]
request: { request: {
/// The Matrix room alias to look up. /// The Matrix room alias to look up.
#[ruma_api(query)] #[ruma_api(query)]
pub alias: RoomAliasId, pub alias: &'a RoomAliasId,
} }
#[non_exhaustive]
response: { response: {
/// List of matched third party locations. /// List of matched third party locations.
#[ruma_api(body)] #[ruma_api(body)]
@ -28,3 +30,17 @@ ruma_api! {
error: crate::Error 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<Location>) -> Self {
Self { locations }
}
}

View File

@ -13,12 +13,14 @@ ruma_api! {
requires_authentication: true, requires_authentication: true,
} }
#[non_exhaustive]
request: { request: {
/// The name of the protocol. /// The name of the protocol.
#[ruma_api(path)] #[ruma_api(path)]
pub protocol: String, pub protocol: &'a str,
} }
#[non_exhaustive]
response: { response: {
/// Metadata about the protocol. /// Metadata about the protocol.
#[ruma_api(body)] #[ruma_api(body)]
@ -27,3 +29,17 @@ ruma_api! {
error: crate::Error 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 }
}
}

View File

@ -15,8 +15,11 @@ ruma_api! {
requires_authentication: true, requires_authentication: true,
} }
#[derive(Default)]
#[non_exhaustive]
request: {} request: {}
#[non_exhaustive]
response: { response: {
/// Metadata about protocols supported by the homeserver. /// Metadata about protocols supported by the homeserver.
#[ruma_api(body)] #[ruma_api(body)]
@ -25,3 +28,17 @@ ruma_api! {
error: crate::Error 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<String, Protocol>) -> Self {
Self { protocols }
}
}

View File

@ -15,10 +15,11 @@ ruma_api! {
requires_authentication: true, requires_authentication: true,
} }
#[non_exhaustive]
request: { request: {
/// The protocol used to communicate to the third party network. /// The protocol used to communicate to the third party network.
#[ruma_api(path)] #[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. /// 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. // The specification is incorrect for this parameter. See matrix-org/matrix-doc#2352.
@ -26,6 +27,7 @@ ruma_api! {
pub fields: BTreeMap<String, String>, pub fields: BTreeMap<String, String>,
} }
#[non_exhaustive]
response: { response: {
/// List of matched third party users. /// List of matched third party users.
#[ruma_api(body)] #[ruma_api(body)]
@ -34,3 +36,17 @@ ruma_api! {
error: crate::Error 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<User>) -> Self {
Self { users }
}
}

View File

@ -14,12 +14,14 @@ ruma_api! {
requires_authentication: true, requires_authentication: true,
} }
#[non_exhaustive]
request: { request: {
/// The Matrix User ID to look up. /// The Matrix User ID to look up.
#[ruma_api(query)] #[ruma_api(query)]
pub userid: UserId, pub userid: &'a UserId,
} }
#[non_exhaustive]
response: { response: {
/// List of matched third party users. /// List of matched third party users.
#[ruma_api(body)] #[ruma_api(body)]
@ -28,3 +30,17 @@ ruma_api! {
error: crate::Error 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<User>) -> Self {
Self { users }
}
}