ruma_client_api/room/
get_room_event.rs

1//! `GET /_matrix/client/*/rooms/{roomId}/event/{eventId}`
2//!
3//! Get a single event based on roomId/eventId
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3roomsroomideventeventid
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata,
13        serde::Raw,
14        OwnedEventId, OwnedRoomId,
15    };
16    use ruma_events::AnyTimelineEvent;
17
18    const METADATA: Metadata = metadata! {
19        method: GET,
20        rate_limited: false,
21        authentication: AccessToken,
22        history: {
23            1.0 => "/_matrix/client/r0/rooms/:room_id/event/:event_id",
24            1.1 => "/_matrix/client/v3/rooms/:room_id/event/:event_id",
25        }
26    };
27
28    /// Request type for the `get_room_event` endpoint.
29    #[request(error = crate::Error)]
30    pub struct Request {
31        /// The ID of the room the event is in.
32        #[ruma_api(path)]
33        pub room_id: OwnedRoomId,
34
35        /// The ID of the event.
36        #[ruma_api(path)]
37        pub event_id: OwnedEventId,
38    }
39
40    /// Response type for the `get_room_event` endpoint.
41    #[response(error = crate::Error)]
42    pub struct Response {
43        /// Arbitrary JSON of the event body.
44        #[ruma_api(body)]
45        pub event: Raw<AnyTimelineEvent>,
46    }
47
48    impl Request {
49        /// Creates a new `Request` with the given room ID and event ID.
50        pub fn new(room_id: OwnedRoomId, event_id: OwnedEventId) -> Self {
51            Self { room_id, event_id }
52        }
53    }
54
55    impl Response {
56        /// Creates a new `Response` with the given event.
57        pub fn new(event: Raw<AnyTimelineEvent>) -> Self {
58            Self { event }
59        }
60    }
61}