Use ruma-api-macros for the typing endpoints.

This commit is contained in:
Jimmy Cuadra 2017-07-07 01:02:03 -07:00
parent 995fa6e1ae
commit 0d9d1f8119
2 changed files with 23 additions and 53 deletions

View File

@ -41,7 +41,7 @@ pub mod r0 {
pub mod session; pub mod session;
pub mod sync; pub mod sync;
pub mod tag; pub mod tag;
// pub mod typing; pub mod typing;
// pub mod voip; // pub mod voip;
} }

View File

@ -2,63 +2,33 @@
/// [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid) /// [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid)
pub mod create_typing_event { pub mod create_typing_event {
use ruma_api_macros::ruma_api;
use ruma_identifiers::{UserId, RoomId}; use ruma_identifiers::{UserId, RoomId};
/// Details about this API endpoint. ruma_api! {
#[derive(Clone, Copy, Debug)] metadata {
pub struct Endpoint; method: Method::Put,
path: "/_matrix/client/r0/rooms/:room_id/typing/:user_id",
/// This API endpoint's path parameters. name: "create_typing_event",
#[derive(Clone, Debug, Deserialize, Serialize)] description: "Send a typing event to a room.",
pub struct PathParams { requires_authentication: true,
pub room_id: RoomId, rate_limited: true,
pub user_id: UserId
}
/// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams {
pub typing: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<u64>
}
impl ::Endpoint for Endpoint {
type BodyParams = BodyParams;
type PathParams = PathParams;
type QueryParams = ();
type Response = ();
fn method() -> ::Method {
::Method::Put
} }
fn request_path(params: Self::PathParams) -> String { request {
format!( /// The room in which the user is typing.
"/_matrix/client/r0/rooms/{}/typing/{}", #[ruma_api(path)]
params.room_id, pub room_id: RoomId,
params.user_id /// The length of time in milliseconds to mark this user as typing.
) #[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<u64>,
/// Whether the user is typing or not. If `false`, the `timeout` key can be omitted.
pub typing: bool,
/// The user who has started to type.
#[ruma_api(path)]
pub user_id: UserId,
} }
fn router_path() -> &'static str { response {}
"/_matrix/client/r0/rooms/:room_id/typing/:user_id"
}
fn name() -> &'static str {
"create_typing_event"
}
fn description() -> &'static str {
"Send a typing event to a room."
}
fn requires_authentication() -> bool {
true
}
fn rate_limited() -> bool {
true
}
} }
} }