Rename HTTP_METHOD to METHOD, document constants, fill in types for remaining session and account endpoints.

This commit is contained in:
Jimmy Cuadra 2016-09-30 17:22:21 -07:00
parent 409b8202f7
commit 11285ddc95
4 changed files with 72 additions and 7 deletions

View File

@ -2,7 +2,10 @@
/// POST /_matrix/client/r0/register
pub mod register {
pub const HTTP_METHOD: &'static str = "POST";
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/register";
/// The kind of account being registered.
@ -34,15 +37,28 @@ pub mod register {
/// POST /_matrix/client/r0/account/password/email/requestToken
pub mod request_password_change_token {
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/account/password/email/requestToken";
}
/// POST /_matrix/client/r0/account/deactivate
pub mod deactivate {
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/account/deactivate";
}
/// POST /_matrix/client/r0/account/password
pub mod change_password {
pub const HTTP_METHOD: &'static str = "POST";
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/account/password";
/// The request type.
@ -54,4 +70,18 @@ pub mod change_password {
/// POST /_matrix/client/r0/register/email/requestToken
pub mod request_register_token {
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/register/email/requestToken";
/// The request type.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Request {
pub client_secret: String,
pub email: String,
pub id_server: Option<String>,
pub send_attempt: u64,
}
}

View File

@ -4,7 +4,10 @@
pub mod create_room {
use ruma_identifiers::RoomId;
pub const HTTP_METHOD: &'static str = "POST";
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/createRoom";
/// Extra options to be added to the `m.room.create` event.

View File

@ -2,20 +2,49 @@
/// POST /_matrix/client/r0/login
pub mod login {
pub const HTTP_METHOD: &'static str = "POST";
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/login";
/// The response type.
#[derive(Clone, Debug, Deserialize, Serialize)]
struct LoginResponse {
pub struct Response {
pub access_token: String,
pub home_server: String,
pub refresh_token: Option<String>,
pub user_id: String,
}
}
/// POST /_matrix/client/r0/logout
pub mod logout {
pub const HTTP_METHOD: &'static str = "POST";
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/logout";
}
/// POST /_matrix/client/r0/tokenrefresh
pub mod refresh_access_token {
/// The HTTP method.
pub const METHOD: &'static str = "POST";
/// The URL's path component.
pub const PATH: &'static str = "/_matrix/client/r0/tokenrefresh";
/// The request type.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Request {
pub refresh_token: String,
}
/// The response type.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub access_token: String,
pub refresh_token: Option<String>,
}
}

View File

@ -1,4 +1,7 @@
pub const HTTP_METHOD: &'static str = "GET";
/// The HTTP method.
pub const METHOD: &'static str = "GET";
/// The URL's path component.
pub const PATH: &'static str = "/versions";
/// The response type.