pub mod v3 {
use std::collections::BTreeMap;
use ruma_common::{
OwnedTransactionId, OwnedUserId,
api::{auth_scheme::AccessToken, request, response},
metadata,
serde::Raw,
to_device::DeviceIdOrAllDevices,
};
use ruma_events::{AnyToDeviceEventContent, ToDeviceEventType};
metadata! {
method: PUT,
rate_limited: false,
authentication: AccessToken,
history: {
1.0 => "/_matrix/client/r0/sendToDevice/{event_type}/{txn_id}",
1.1 => "/_matrix/client/v3/sendToDevice/{event_type}/{txn_id}",
}
}
#[request(error = crate::Error)]
pub struct Request {
#[ruma_api(path)]
pub event_type: ToDeviceEventType,
#[ruma_api(path)]
pub txn_id: OwnedTransactionId,
pub messages: Messages,
}
#[response(error = crate::Error)]
#[derive(Default)]
pub struct Response {}
impl Request {
pub fn new_raw(
event_type: ToDeviceEventType,
txn_id: OwnedTransactionId,
messages: Messages,
) -> Self {
Self { event_type, txn_id, messages }
}
}
impl Response {
pub fn new() -> Self {
Self {}
}
}
pub type Messages =
BTreeMap<OwnedUserId, BTreeMap<DeviceIdOrAllDevices, Raw<AnyToDeviceEventContent>>>;
}