ruma_client_api/push/
get_pushrule.rs

1//! `GET /_matrix/client/*/pushrules/global/{kind}/{ruleId}`
2//!
3//! Retrieve a single specified push rule.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrulesglobalkindruleid
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata,
13    };
14
15    use crate::push::{PushRule, RuleKind};
16
17    const METADATA: Metadata = metadata! {
18        method: GET,
19        rate_limited: false,
20        authentication: AccessToken,
21        history: {
22            1.0 => "/_matrix/client/r0/pushrules/global/:kind/:rule_id",
23            1.1 => "/_matrix/client/v3/pushrules/global/:kind/:rule_id",
24        }
25    };
26
27    /// Request type for the `get_pushrule` endpoint.
28    #[request(error = crate::Error)]
29    pub struct Request {
30        /// The kind of rule.
31        #[ruma_api(path)]
32        pub kind: RuleKind,
33
34        /// The identifier for the rule.
35        #[ruma_api(path)]
36        pub rule_id: String,
37    }
38
39    /// Response type for the `get_pushrule` endpoint.
40    #[response(error = crate::Error)]
41    pub struct Response {
42        /// The specific push rule.
43        #[ruma_api(body)]
44        pub rule: PushRule,
45    }
46
47    impl Request {
48        /// Creates a new `Request` with the given rule kind and rule ID.
49        pub fn new(kind: RuleKind, rule_id: String) -> Self {
50            Self { kind, rule_id }
51        }
52    }
53
54    impl Response {
55        /// Creates a new `Response` with the given rule.
56        pub fn new(rule: PushRule) -> Self {
57            Self { rule }
58        }
59    }
60}