libmatrix-client/src/api/methods/login.rs

57 lines
1.5 KiB
Rust
Raw Normal View History

2019-08-21 22:00:24 +00:00
use serde::{Deserialize, Serialize};
// 5.4.1 GET /_matrix/client/r0/login
2019-08-20 23:53:31 +00:00
/// Response for 5.4.1: GET /_matrix/client/r0/login
#[derive(Deserialize)]
pub struct ValidLoginFlows {
pub flows: Option<LoginFlow>,
}
#[derive(Deserialize)]
pub struct LoginFlow {
pub r#type: Option<String>,
}
2019-08-21 22:00:24 +00:00
// 5.4.2 POST /_matrix/client/r0/login
/// Known identifier types for authentication methods. See [Section 5.3.6](https://matrix.org/docs/spec/client_server/r0.5.0#identifier-types)
/// for more details.
#[derive(Deserialize, Serialize)]
2019-08-22 00:54:43 +00:00
#[serde(tag = "type")]
2019-08-21 22:00:24 +00:00
pub enum IdentifierType {
#[serde(rename = "m.id.user")]
2019-08-22 00:54:43 +00:00
User { user: String },
2019-08-21 22:00:24 +00:00
#[serde(rename = "m.id.thirdparty")]
2019-08-22 00:54:43 +00:00
ThirdParty { medium: String, address: String },
2019-08-21 22:00:24 +00:00
#[serde(rename = "m.id.phone")]
2019-08-22 00:54:43 +00:00
Phone { country: String, phone: String },
2019-08-21 22:00:24 +00:00
}
2019-08-20 23:53:31 +00:00
2019-08-21 22:00:24 +00:00
/// Response for a valid login from 5.4.2: POST /_matrix/client/r0/login
#[derive(Deserialize)]
2019-08-20 23:53:31 +00:00
pub struct LoginResponse {
pub user_id: Option<String>,
pub access_token: Option<String>,
pub home_server: Option<String>,
pub device_id: Option<String>,
pub well_known: Option<DiscoveryInformation>,
}
2019-08-21 22:00:24 +00:00
#[derive(Deserialize)]
2019-08-22 01:41:51 +00:00
pub struct DiscoveryInformation {
#[serde(rename = "m.homeserver")]
pub homeserver: HomeserverInformation,
#[serde(rename = "m.identity_server")]
pub identity_server: Option<IdentityServerInformation>,
}
#[derive(Deserialize)]
pub struct HomeserverInformation {
pub base_url: String,
}
#[derive(Deserialize)]
pub struct IdentityServerInformation {
pub base_url: String,
}