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