client-api: Reorder fields and ctor parameters for account data endpoints
This commit is contained in:
parent
2b4ac40981
commit
661f6e60bd
@ -11,6 +11,7 @@ Breaking changes:
|
|||||||
* Since `backward` and `forward` are equivalent to `from_end` and `from_start`, those are removed
|
* Since `backward` and `forward` are equivalent to `from_end` and `from_start`, those are removed
|
||||||
* A new method `.from()` was added to easily set this field after initial construction
|
* A new method `.from()` was added to easily set this field after initial construction
|
||||||
* `receipt::create_receipt` uses its own `ReceiptType`
|
* `receipt::create_receipt` uses its own `ReceiptType`
|
||||||
|
* Reorder parameters in `{set_global_account_data, set_room_account_data}::Request::{new, new_raw}`
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ pub mod v3 {
|
|||||||
///
|
///
|
||||||
/// Since `Request` stores the request body in serialized form, this function can fail if
|
/// Since `Request` stores the request body in serialized form, this function can fail if
|
||||||
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
||||||
pub fn new<T>(data: &'a T, user_id: &'a UserId) -> serde_json::Result<Self>
|
pub fn new<T>(user_id: &'a UserId, data: &'a T) -> serde_json::Result<Self>
|
||||||
where
|
where
|
||||||
T: GlobalAccountDataEventContent,
|
T: GlobalAccountDataEventContent,
|
||||||
{
|
{
|
||||||
@ -74,9 +74,9 @@ pub mod v3 {
|
|||||||
|
|
||||||
/// Creates a new `Request` with the given raw data, event type and user ID.
|
/// Creates a new `Request` with the given raw data, event type and user ID.
|
||||||
pub fn new_raw(
|
pub fn new_raw(
|
||||||
data: Raw<AnyGlobalAccountDataEventContent>,
|
|
||||||
event_type: GlobalAccountDataEventType,
|
|
||||||
user_id: &'a UserId,
|
user_id: &'a UserId,
|
||||||
|
event_type: GlobalAccountDataEventType,
|
||||||
|
data: Raw<AnyGlobalAccountDataEventContent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { user_id, event_type, data }
|
Self { user_id, event_type, data }
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,15 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request: {
|
request: {
|
||||||
/// Arbitrary JSON to store as config data.
|
/// The ID of the user to set account_data for.
|
||||||
///
|
///
|
||||||
/// To create a `RawJsonValue`, use `serde_json::value::to_raw_value`.
|
/// The access token must be authorized to make requests for this user ID.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(path)]
|
||||||
pub data: Raw<AnyRoomAccountDataEventContent>,
|
pub user_id: &'a UserId,
|
||||||
|
|
||||||
|
/// The ID of the room to set account_data on.
|
||||||
|
#[ruma_api(path)]
|
||||||
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// The event type of the account_data to set.
|
/// The event type of the account_data to set.
|
||||||
///
|
///
|
||||||
@ -40,15 +44,11 @@ pub mod v3 {
|
|||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_type: RoomAccountDataEventType,
|
pub event_type: RoomAccountDataEventType,
|
||||||
|
|
||||||
/// The ID of the room to set account_data on.
|
/// Arbitrary JSON to store as config data.
|
||||||
#[ruma_api(path)]
|
|
||||||
pub room_id: &'a RoomId,
|
|
||||||
|
|
||||||
/// The ID of the user to set account_data for.
|
|
||||||
///
|
///
|
||||||
/// The access token must be authorized to make requests for this user ID.
|
/// To create a `RawJsonValue`, use `serde_json::value::to_raw_value`.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(body)]
|
||||||
pub user_id: &'a UserId,
|
pub data: Raw<AnyRoomAccountDataEventContent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -65,29 +65,29 @@ pub mod v3 {
|
|||||||
/// Since `Request` stores the request body in serialized form, this function can fail if
|
/// Since `Request` stores the request body in serialized form, this function can fail if
|
||||||
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
/// `T`s [`Serialize`][serde::Serialize] implementation can fail.
|
||||||
pub fn new<T>(
|
pub fn new<T>(
|
||||||
data: &'a T,
|
|
||||||
room_id: &'a RoomId,
|
|
||||||
user_id: &'a UserId,
|
user_id: &'a UserId,
|
||||||
|
room_id: &'a RoomId,
|
||||||
|
data: &'a T,
|
||||||
) -> serde_json::Result<Self>
|
) -> serde_json::Result<Self>
|
||||||
where
|
where
|
||||||
T: RoomAccountDataEventContent,
|
T: RoomAccountDataEventContent,
|
||||||
{
|
{
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
data: Raw::from_json(to_raw_json_value(data)?),
|
|
||||||
event_type: data.event_type(),
|
|
||||||
room_id,
|
|
||||||
user_id,
|
user_id,
|
||||||
|
room_id,
|
||||||
|
event_type: data.event_type(),
|
||||||
|
data: Raw::from_json(to_raw_json_value(data)?),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `Request` with the given raw data, event type, room ID and user ID.
|
/// Creates a new `Request` with the given raw data, event type, room ID and user ID.
|
||||||
pub fn new_raw(
|
pub fn new_raw(
|
||||||
data: Raw<AnyRoomAccountDataEventContent>,
|
|
||||||
event_type: RoomAccountDataEventType,
|
|
||||||
room_id: &'a RoomId,
|
|
||||||
user_id: &'a UserId,
|
user_id: &'a UserId,
|
||||||
|
room_id: &'a RoomId,
|
||||||
|
event_type: RoomAccountDataEventType,
|
||||||
|
data: Raw<AnyRoomAccountDataEventContent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { data, event_type, room_id, user_id }
|
Self { user_id, room_id, event_type, data }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user