Merge pull request #6 from vberger/master

Add more endpoints (publicrooms, profile, filter, events)
This commit is contained in:
Jimmy Cuadra 2016-12-29 05:01:39 -08:00 committed by GitHub
commit afc2a314cc
16 changed files with 740 additions and 5 deletions

View File

@ -22,6 +22,7 @@ pub mod r0 {
pub mod contact; pub mod contact;
pub mod context; pub mod context;
pub mod directory; pub mod directory;
pub mod events;
pub mod filter; pub mod filter;
pub mod media; pub mod media;
pub mod membership; pub mod membership;

View File

@ -7,8 +7,10 @@ pub mod register {
/// This API endpoint's body parameters. /// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub bind_email: Option<bool>, pub bind_email: Option<bool>,
pub password: String, pub password: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>, pub username: Option<String>,
} }
@ -16,8 +18,9 @@ pub mod register {
pub struct Endpoint; pub struct Endpoint;
/// This API endpoint's query string parameters. /// This API endpoint's query string parameters.
#[derive(Clone, Debug)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct QueryParams { pub struct QueryParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub kind: Option<RegistrationKind>, pub kind: Option<RegistrationKind>,
} }
@ -67,6 +70,7 @@ pub mod request_password_change_token {
pub struct BodyParams { pub struct BodyParams {
pub client_secret: String, pub client_secret: String,
pub email: String, pub email: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub id_server: Option<String>, pub id_server: Option<String>,
pub send_attempt: u64, pub send_attempt: u64,
} }
@ -163,6 +167,7 @@ pub mod request_register_token {
pub struct BodyParams { pub struct BodyParams {
pub client_secret: String, pub client_secret: String,
pub email: String, pub email: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub id_server: Option<String>, pub id_server: Option<String>,
pub send_attempt: u64, pub send_attempt: u64,
} }

View File

@ -101,6 +101,7 @@ pub mod get {
} }
/// These API endpoints' path parameters. /// These API endpoints' path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams { pub struct PathParams {
pub room_alias: RoomAliasId, pub room_alias: RoomAliasId,
} }

View File

@ -7,6 +7,7 @@ pub mod add_contact {
/// This API endpoint's body parameters. /// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub bind: Option<bool>, pub bind: Option<bool>,
pub three_pid_creds: ThreePidCredentials, pub three_pid_creds: ThreePidCredentials,
} }
@ -98,6 +99,7 @@ pub mod request_contact_verification_token {
pub struct BodyParams { pub struct BodyParams {
pub client_secret: String, pub client_secret: String,
pub email: String, pub email: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub id_server: Option<String>, pub id_server: Option<String>,
pub send_attempt: u64, pub send_attempt: u64,
} }

View File

@ -19,7 +19,7 @@ pub mod get_context {
} }
/// This API endpoint's query string parameters. /// This API endpoint's query string parameters.
#[derive(Clone, Debug)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct QueryParams { pub struct QueryParams {
pub limit: u8, pub limit: u8,
} }

View File

@ -1 +1,54 @@
//! Endpoints for the public room directory. //! Endpoints for the public room directory.
/// GET /_matrix/client/r0/publicRooms
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-publicrooms)
pub mod public_rooms {
use ruma_identifiers::{RoomId, RoomAliasId};
/// A chunk of the response, describing one room
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PublicRoomsChunk {
pub world_readable: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub topic: Option<String>,
pub num_joined_members: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>,
pub room_id: RoomId,
pub guest_can_join: bool,
pub aliases: Vec<RoomAliasId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>
}
/// This API response type
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub start: String,
pub chunk: Vec<PublicRoomsChunk>,
pub end: String
}
/// Details about this API endpoint.
pub struct Endpoint;
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/publicRooms".to_string()
}
}
}

235
src/r0/events.rs Normal file
View File

@ -0,0 +1,235 @@
//! Endpoints for getting events
/// GET /_matrix/client/r0/rooms/{roomId}/state
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state)
pub mod get_full_state {
use ruma_identifiers::RoomId;
use ruma_events::collections::only;
/// Details about this API endpoint.
pub struct Endpoint;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub room_id: RoomId
}
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = ();
type Response = Vec<only::StateEvent>;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/rooms/{}/state",
params.room_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/rooms/:room_id/state".to_string()
}
}
}
/// GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype)
pub mod get_state_for_empty_key {
use ruma_identifiers::RoomId;
/// Details about this API endpoint.
pub struct Endpoint;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub room_id: RoomId,
pub event_type: String
}
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = ();
type Response = ::serde_json::Value;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/rooms/{}/state/{}",
params.room_id,
params.event_type
)
}
fn router_path() -> String {
"/_matrix/client/r0/rooms/:room_id/state/:event_type".to_string()
}
}
}
/// GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-state-key)
pub mod get_state_for_key {
use ruma_identifiers::RoomId;
/// Details about this API endpoint.
pub struct Endpoint;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub room_id: RoomId,
pub event_type: String,
pub state_key: String,
}
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = ();
type Response = ::serde_json::Value;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/rooms/{}/state/{}/{}",
params.room_id,
params.event_type,
params.state_key
)
}
fn router_path() -> String {
"/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key".to_string()
}
}
}
/// GET /_matrix/client/r0/rooms/{roomId}/members
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-members)
pub mod get_members {
use ruma_identifiers::RoomId;
use ruma_events::room::member::MemberEvent;
/// Details about this API endpoint.
pub struct Endpoint;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub room_id: RoomId,
pub event_type: String
}
/// This API endpoint's reponse.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub chunks: Vec<MemberEvent>
}
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = ();
type Response = Response;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/rooms/{}/members",
params.room_id,
)
}
fn router_path() -> String {
"/_matrix/client/r0/rooms/:room_id/members".to_string()
}
}
}
/// GET /_matrix/client/r0/rooms/{roomId}/messages
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-messages)
pub mod get_messages {
use ruma_identifiers::RoomId;
use ruma_events::collections::only;
/// Details about this API endpoint.
pub struct Endpoint;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub room_id: RoomId,
pub event_type: String
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Direction {
#[serde(rename="b")]
Backward,
#[serde(rename="f")]
Forward
}
/// This API endpoint's query parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct QueryParams {
pub from: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub to: Option<String>,
pub dir: Direction,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u64>
}
/// This API endpoint's reponse.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub start: String,
pub chunks: Vec<only::RoomEvent>,
pub end: String
}
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = QueryParams;
type Response = Response;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/rooms/{}/messages",
params.room_id,
)
}
fn router_path() -> String {
"/_matrix/client/r0/rooms/:room_id/messages".to_string()
}
}
}

View File

@ -1 +1,181 @@
//! Endpoints for event filters. //! Endpoints for event filters.
use ruma_identifiers::{RoomId, UserId};
/// Format to use for returned events
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
pub enum EventFormat {
/// Client format, as described in the Client API
#[serde(rename="client")]
Client,
/// Raw events from federation
#[serde(rename="federation")]
Federation
}
/// Filters to be applied to room events
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RoomEventFilter {
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub not_types: Vec<String>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub not_rooms: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u64>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub rooms: Vec<RoomId>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub not_senders: Vec<UserId>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub senders: Vec<UserId>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub types: Vec<String>
}
/// Filters to be applied to room data
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RoomFilter {
#[serde(skip_serializing_if = "Option::is_none")]
pub include_leave: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub account_data: Option<RoomEventFilter>,
#[serde(skip_serializing_if = "Option::is_none")]
pub timeline: Option<RoomEventFilter>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ephemeral: Option<RoomEventFilter>,
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<RoomEventFilter>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub not_rooms: Vec<RoomId>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub room: Vec<RoomId>
}
/// Filter for not-room data
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Filter {
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub not_types: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u64>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub senders: Vec<UserId>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub types: Vec<String>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub not_senders: Vec<UserId>
}
/// A filter definition
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct FilterDefinition {
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub event_fields: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub event_format: Option<EventFormat>,
#[serde(skip_serializing_if = "Option::is_none")]
pub account_data: Option<Filter>,
#[serde(skip_serializing_if = "Option::is_none")]
pub room: Option<RoomFilter>,
#[serde(skip_serializing_if = "Option::is_none")]
pub presence: Option<Filter>
}
/// POST /_matrix/client/r0/user/{userId}/filter
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-user-userid-filter)
pub mod create_filter {
use ruma_identifiers::UserId;
use super::FilterDefinition;
/// Details about this API endpoint.
pub struct Endpoint;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub user_id: UserId
}
/// This API Response.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub filter_id: String
}
impl ::Endpoint for Endpoint {
type BodyParams = FilterDefinition;
type PathParams = PathParams;
type QueryParams = ();
type Response = Response;
fn method() -> ::Method {
::Method::Post
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/user/{}/filter",
params.user_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/user/:user_id/filter".to_string()
}
}
}
/// GET /_matrix/client/r0/user/{userId}/filter/{filterId}
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-user-userid-filter-filterid)
pub mod get_filter {
use ruma_identifiers::UserId;
use super::FilterDefinition;
/// Details about this API endpoint.
pub struct Endpoint;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub user_id: UserId,
pub filter_id: String
}
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = ();
type Response = FilterDefinition;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/user/{}/filter/{}",
params.user_id,
params.filter_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/user/:user_id/filter/:filter_id".to_string()
}
}
}

View File

@ -69,6 +69,7 @@ pub mod join_by_room_id_or_alias {
/// The request type. /// The request type.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub third_party_signed: Option<ThirdPartySigned>, pub third_party_signed: Option<ThirdPartySigned>,
} }
@ -130,6 +131,7 @@ pub mod join_by_room_id {
/// The request type. /// The request type.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub third_party_signed: Option<ThirdPartySigned>, pub third_party_signed: Option<ThirdPartySigned>,
} }
@ -257,6 +259,7 @@ pub mod kick {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
pub user_id: String, pub user_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>, pub reason: Option<String>,
} }
@ -345,6 +348,7 @@ pub mod ban {
/// The request type. /// The request type.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>, pub reason: Option<String>,
pub user_id: String, pub user_id: String,
} }

View File

@ -19,6 +19,7 @@ pub mod set_presence {
/// This API endpoint's body parameters. /// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
status_msg: Option<String>, status_msg: Option<String>,
presence: PresenceState presence: PresenceState
} }
@ -65,8 +66,11 @@ pub mod get_presence {
/// This API endpoint's response. /// This API endpoint's response.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response { pub struct Response {
#[serde(skip_serializing_if = "Option::is_none")]
pub status_msg: Option<String>, pub status_msg: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub currently_active: Option<bool>, pub currently_active: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_active_ago: Option<u64>, pub last_active_ago: Option<u64>,
pub presence: PresenceState pub presence: PresenceState
} }
@ -112,8 +116,12 @@ pub mod update_presence_list {
/// This API endpoint's body parameters. /// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
drop: Option<Vec<UserId>>, #[serde(skip_serializing_if = "Vec::is_empty")]
invite: Option<Vec<UserId>> #[serde(default)]
drop: Vec<UserId>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
invite: Vec<UserId>
} }
impl ::Endpoint for Endpoint { impl ::Endpoint for Endpoint {

View File

@ -1 +1,229 @@
//! Endpoints for user profiles. //! Endpoints for user profiles.
/// GET /_matrix/client/r0/profile/{userId}/displayname
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-displayname)
pub mod get_display_name {
use ruma_identifiers::UserId;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub user_id: UserId
}
/// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
#[serde(skip_serializing_if = "Option::is_none")]
pub displayname: Option<String>
}
/// Details about this API endpoint.
pub struct Endpoint;
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = ();
type Response = Response;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/profile/{}/displayname",
params.user_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/profile/:user_id/displayname".to_string()
}
}
}
/// PUT /_matrix/client/r0/profile/{userId}/displayname
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-displayname)
pub mod set_display_name {
use ruma_identifiers::UserId;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub user_id: UserId
}
/// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub displayname: Option<String>
}
/// Details about this API endpoint.
pub struct Endpoint;
impl ::Endpoint for Endpoint {
type BodyParams = BodyParams;
type PathParams = PathParams;
type QueryParams = ();
type Response = ();
fn method() -> ::Method {
::Method::Put
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/profile/{}/displayname",
params.user_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/profile/:user_id/displayname".to_string()
}
}
}
/// GET /_matrix/client/r0/profile/{userId}/avatar_url
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-avatar-url)
pub mod get_avatar_url {
use ruma_identifiers::UserId;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub user_id: UserId
}
/// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>
}
/// Details about this API endpoint.
pub struct Endpoint;
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = ();
type Response = Response;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/profile/{}/avatar_url",
params.user_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/profile/:user_id/avatar_url".to_string()
}
}
}
/// PUT /_matrix/client/r0/profile/{userId}/avatar_url
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-avatar-url)
pub mod set_avatar_url {
use ruma_identifiers::UserId;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub user_id: UserId
}
/// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>
}
/// Details about this API endpoint.
pub struct Endpoint;
impl ::Endpoint for Endpoint {
type BodyParams = BodyParams;
type PathParams = PathParams;
type QueryParams = ();
type Response = ();
fn method() -> ::Method {
::Method::Put
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/profile/{}/avatar_url",
params.user_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/profile/:user_id/avatar_url".to_string()
}
}
}
/// GET /_matrix/client/r0/profile/{userId}
///
/// [Matrix spec link](http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid)
pub mod get_profile {
use ruma_identifiers::UserId;
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub user_id: UserId
}
/// This API endpoint's body parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub displayname: Option<String>
}
/// Details about this API endpoint.
pub struct Endpoint;
impl ::Endpoint for Endpoint {
type BodyParams = ();
type PathParams = PathParams;
type QueryParams = ();
type Response = Response;
fn method() -> ::Method {
::Method::Get
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/profile/{}",
params.user_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/profile/:user_id".to_string()
}
}
}

View File

@ -20,6 +20,7 @@ pub mod send_event {
/// This API endpoint's path parameters. /// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String> pub reason: Option<String>
} }

View File

@ -9,12 +9,20 @@ pub mod create_room {
/// The request type. /// The request type.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub creation_content: Option<CreationContent>, pub creation_content: Option<CreationContent>,
pub invite: Option<Vec<String>>, #[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub invite: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>, pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub preset: Option<RoomPreset>, pub preset: Option<RoomPreset>,
#[serde(skip_serializing_if = "Option::is_none")]
pub room_alias_name: Option<String>, pub room_alias_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub topic: Option<String>, pub topic: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub visibility: Option<String>, pub visibility: Option<String>,
} }
@ -22,6 +30,7 @@ pub mod create_room {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreationContent { pub struct CreationContent {
#[serde(rename="m.federate")] #[serde(rename="m.federate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub federate: Option<bool>, pub federate: Option<bool>,
} }

View File

@ -12,6 +12,7 @@ pub mod login {
pub struct Response { 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")]
pub refresh_token: Option<String>, pub refresh_token: Option<String>,
pub user_id: String, pub user_id: String,
} }
@ -80,6 +81,7 @@ pub mod refresh_access_token {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response { pub struct Response {
pub access_token: String, pub access_token: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<String>, pub refresh_token: Option<String>,
} }

View File

@ -21,10 +21,15 @@ pub mod sync {
/// This API endpoint's query parameters. /// This API endpoint's query parameters.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct QueryParams { pub struct QueryParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<String>, pub filter: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub since: Option<String>, pub since: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub full_state: Option<bool>, pub full_state: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub set_presence: Option<SetPresence>, pub set_presence: Option<SetPresence>,
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<u64> pub timeout: Option<u64>
} }

View File

@ -20,6 +20,7 @@ pub mod set_typing {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams { pub struct BodyParams {
pub typing: bool, pub typing: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<u64> pub timeout: Option<u64>
} }