zulip_api/message/webhook_config.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents webhook config option details.
6///
7/// Modified from `openapi-generator-cli` output:
8///
9/// ```shell,no_build,no_run
10/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
11/// ```
12///
13/// ```text
14/// /*
15/// * Zulip REST API
16/// *
17/// * Powerful open source group chat
18/// *
19/// * The version of the OpenAPI document: 1.0.0
20/// *
21/// * Generated by: https://openapi-generator.tech
22/// */
23/// ```
24///
25/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
26///
27/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
28#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
29pub struct WebhookConfigOption {
30 /// A key for the configuration option.
31 #[serde(skip_serializing_if = "Option::is_none")]
32 key: Option<String>,
33 /// A human-readable label of the configuration option.
34 #[serde(skip_serializing_if = "Option::is_none")]
35 label: Option<String>,
36 /// The name of the validator function for the configuration option.
37 #[serde(skip_serializing_if = "Option::is_none")]
38 validator: Option<String>,
39}
40
41impl WebhookConfigOption {
42 /// Create a new [WebhookConfigOption].
43 pub const fn new() -> Self {
44 Self {
45 key: None,
46 label: None,
47 validator: None,
48 }
49 }
50}
51
52field_access! {
53 WebhookConfigOption {
54 /// A key for the configuration option.
55 key: option_cow_deref { str, String },
56 /// A human-readable label of the configuration option.
57 label: option_cow_deref { str, String },
58 /// The name of the validator function for the configuration option.
59 validator: option_cow_deref { str, String },
60 }
61}
62
63impl_default!(WebhookConfigOption);
64impl_display!(WebhookConfigOption);
65
66/// Represents an optional URL parameter options for the incoming webhook integration.
67///
68/// This is an unstable API expected to be used only by the Zulip web app. Please discuss in chat.zulip.org before using it.
69///
70/// **Changes**: New in Zulip 11.0 (feature level 403). Previously, these optional URL parameter options were included in the `config_options` object.
71#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
72pub struct WebhookUrlOption {
73 #[serde(skip_serializing_if = "Option::is_none")]
74 key: Option<String>,
75 #[serde(skip_serializing_if = "Option::is_none")]
76 label: Option<String>,
77 #[serde(skip_serializing_if = "Option::is_none")]
78 validator: Option<String>,
79}
80
81impl WebhookUrlOption {
82 /// Creates a new [WebhookUrlOption].
83 pub const fn new() -> Self {
84 Self {
85 key: None,
86 label: None,
87 validator: None,
88 }
89 }
90}
91
92field_access! {
93 WebhookUrlOption {
94 /// The parameter variable to encode the users input for this option in the integrations webhook URL.
95 key: option_cow_deref { str, String },
96 /// A human-readable label of the url option.
97 label: option_cow_deref { str, String },
98 /// The name of the validator function for the configuration option.
99 validator: option_cow_deref { str, String },
100 }
101}
102
103impl_default!(WebhookUrlOption);
104impl_display!(WebhookUrlOption);