Port session.rs to ruma_api_macro
This commit is contained in:
parent
f715124190
commit
a097aa02f2
@ -2,27 +2,18 @@
|
|||||||
|
|
||||||
/// [POST /_matrix/client/r0/login](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login)
|
/// [POST /_matrix/client/r0/login](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login)
|
||||||
pub mod login {
|
pub mod login {
|
||||||
/// Details about this API endpoint.
|
use ruma_api_macros::ruma_api;
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
/// Possible login mediums for 3rd party ID
|
ruma_api! {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
metadata {
|
||||||
pub enum LoginMedium {
|
description: "Login to the homeserver.",
|
||||||
#[serde(rename = "email")]
|
method: ::Method::Post,
|
||||||
Email
|
name: "login",
|
||||||
|
path: "/_matrix/client/r0/login",
|
||||||
|
rate_limited: true,
|
||||||
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
request {
|
||||||
/// Possible kinds of login
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub enum LoginKind {
|
|
||||||
#[serde(rename = "m.login.password")]
|
|
||||||
Password
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The body parameters for this endpoint
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct BodyParams {
|
|
||||||
/// Password of the user
|
/// Password of the user
|
||||||
pub password: String,
|
pub password: String,
|
||||||
/// Medium of 3rd party login to use
|
/// Medium of 3rd party login to use
|
||||||
@ -37,10 +28,7 @@ pub mod login {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub address: Option<String>
|
pub address: Option<String>
|
||||||
}
|
}
|
||||||
|
response {
|
||||||
/// This API endpoint's response.
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Response {
|
|
||||||
pub access_token: String,
|
pub access_token: String,
|
||||||
pub home_server: String,
|
pub home_server: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -48,80 +36,34 @@ pub mod login {
|
|||||||
pub user_id: String,
|
pub user_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
/// Possible login mediums for 3rd party ID
|
||||||
type BodyParams = ();
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
type PathParams = ();
|
pub enum LoginMedium {
|
||||||
type QueryParams = ();
|
#[serde(rename = "email")]
|
||||||
type Response = Response;
|
Email
|
||||||
|
|
||||||
fn method() -> ::Method {
|
|
||||||
::Method::Post
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_path(_params: Self::PathParams) -> String {
|
/// Possible kinds of login
|
||||||
Self::router_path().to_string()
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
}
|
pub enum LoginKind {
|
||||||
|
#[serde(rename = "m.login.password")]
|
||||||
fn router_path() -> &'static str {
|
Password
|
||||||
"/_matrix/client/r0/login"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"login"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Login to the homeserver."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-logout)
|
/// [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-logout)
|
||||||
pub mod logout {
|
pub mod logout {
|
||||||
/// Details about this API endpoint.
|
use ruma_api_macros::ruma_api;
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct Endpoint;
|
|
||||||
|
|
||||||
impl ::Endpoint for Endpoint {
|
ruma_api! {
|
||||||
type BodyParams = ();
|
metadata {
|
||||||
type PathParams = ();
|
description: "Log out of the homeserver.",
|
||||||
type QueryParams = ();
|
method: ::Method::Post,
|
||||||
type Response = ();
|
name: "logout",
|
||||||
|
path: "/_matrix/client/r0/logout",
|
||||||
fn method() -> ::Method {
|
rate_limited: false,
|
||||||
::Method::Post
|
requires_authentication: true,
|
||||||
}
|
|
||||||
|
|
||||||
fn request_path(_params: Self::PathParams) -> String {
|
|
||||||
Self::router_path().to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn router_path() -> &'static str {
|
|
||||||
"/_matrix/client/r0/logout"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name() -> &'static str {
|
|
||||||
"logout"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn description() -> &'static str {
|
|
||||||
"Log out of the homeserver."
|
|
||||||
}
|
|
||||||
|
|
||||||
fn requires_authentication() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rate_limited() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
request {}
|
||||||
|
response {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user