Add types for account contact information endpoints.

This commit is contained in:
Jimmy Cuadra 2016-10-01 03:53:43 -07:00
parent 29cbb4c0c7
commit b992542fae

View File

@ -1 +1,120 @@
//! Endpoints for account contact information.
/// POST /_matrix/client/r0/account/3pid
pub mod add_contact {
/// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams {
pub bind: Option<bool>,
pub three_pid_creds: ThreePidCredentials,
}
/// Details about this API endpoint.
pub struct Endpoint;
/// The third party credentials to associate with the account.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThreePidCredentials {
client_secret: String,
id_server: String,
sid: String,
}
impl ::Endpoint for Endpoint {
type BodyParams = BodyParams;
type PathParams = ();
type QueryParams = ();
type Response = ();
fn method() -> ::Method {
::Method::Post
}
fn request_path(_params: Self::PathParams) -> String {
Self::router_path()
}
fn router_path() -> String {
"/_matrix/client/r0/account/3pid".to_string()
}
}
}
/// GET /_matrix/client/r0/account/3pid
pub mod get_contacts {
/// Details about this API endpoint.
pub struct Endpoint;
/// The medium of third party identifier.
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub enum Medium {
#[serde(rename="email")]
Email,
}
/// This API endpoint's response.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub threepids: Vec<ThirdPartyIdentifier>,
}
/// An identifier external to Matrix.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThirdPartyIdentifier {
pub address: String,
pub medium: Medium,
}
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = ();
type QueryParams = ();
type Response = Response;
fn method() -> ::Method {
::Method::Get
}
fn request_path(_params: Self::PathParams) -> String {
Self::router_path()
}
fn router_path() -> String {
"/_matrix/client/r0/account/3pid/email/requestToken".to_string()
}
}
}
/// POST /_matrix/client/r0/account/3pid/email/requestToken
pub mod request_contact_verification_token {
/// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams {
pub client_secret: String,
pub email: String,
pub id_server: Option<String>,
pub send_attempt: u64,
}
/// Details about this API endpoint.
pub struct Endpoint;
impl ::Endpoint for Endpoint {
type BodyParams = BodyParams;
type PathParams = ();
type QueryParams = ();
type Response = ();
fn method() -> ::Method {
::Method::Post
}
fn request_path(_params: Self::PathParams) -> String {
Self::router_path()
}
fn router_path() -> String {
"/_matrix/client/r0/account/3pid/email/requestToken".to_string()
}
}
}