Skip to main content

zulip_api/message/
realm_incoming_webhook_bot.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display, WebhookConfigOption, WebhookUrlOption};
4
5/// Represents details of the incoming webhook bot.
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 RealmIncomingWebhookBot {
30    #[serde(skip_serializing_if = "Option::is_none")]
31    name: Option<String>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    display_name: Option<String>,
34    #[serde(skip_serializing_if = "Option::is_none")]
35    all_event_types: Option<Vec<String>>,
36    #[serde(rename = "config_options", skip_serializing_if = "Option::is_none")]
37    config_options: Option<Vec<WebhookConfigOption>>,
38    #[serde(rename = "url_options", skip_serializing_if = "Option::is_none")]
39    url_options: Option<Vec<WebhookUrlOption>>,
40}
41
42impl RealmIncomingWebhookBot {
43    /// Object containing details of the bot.
44    pub const fn new() -> Self {
45        Self {
46            name: None,
47            display_name: None,
48            all_event_types: None,
49            config_options: None,
50            url_options: None,
51        }
52    }
53}
54
55field_access! {
56    RealmIncomingWebhookBot {
57        /// A machine-readable unique name identifying the integration, all-lower-case without spaces.
58        name: option_cow_deref { str, String },
59        /// A human-readable display name identifying the integration that this bot implements, intended to be used in menus for selecting which integration to create.
60        ///
61        /// **Changes**: New in Zulip 8.0 (feature level 207).
62        display_name: option_cow_deref { str, String },
63        /// For incoming webhook integrations that support the Zulip server filtering incoming events, the list of event types supported by it.
64        ///
65        /// A null value will be present if this incoming webhook integration doesn't support such filtering.
66        ///
67        /// **Changes**: New in Zulip 8.0 (feature level 207).
68        all_event_types: option_cow_deref { [String], Vec<String> },
69        /// An array of configuration options that can be set when creating a bot user for this incoming webhook integration.
70        ///
71        /// This is an unstable API. Please discuss in chat.zulip.org before using it.
72        ///
73        /// **Changes**: As of Zulip 11.0 (feature level 403), this object is reserved for integration-specific configuration options that can be set when creating a bot user.
74        /// Previously, this object also included optional webhook URL parameters, which are now specified in the `url_options` object.  Before Zulip 10.0 (feature level 318),
75        /// this field was named `config`, and was reserved for configuration data key-value pairs.
76        config_options: option_cow_deref { [WebhookConfigOption], Vec<WebhookConfigOption> },
77        /// An array of optional URL parameter options for the incoming webhook integration.
78        ///
79        /// In the web app, these are used when [generating a URL for an integration](https://zulip.com/help/generate-integration-url).
80        ///
81        /// This is an unstable API expected to be used only by the Zulip web app. Please discuss in chat.zulip.org before using it.
82        ///
83        /// **Changes**: New in Zulip 11.0 (feature level 403). Previously, these optional URL parameter options were included in the `config_options` object.
84        url_options: option_cow_deref { [WebhookUrlOption], Vec<WebhookUrlOption> },
85    }
86}
87
88impl_default!(RealmIncomingWebhookBot);
89impl_display!(RealmIncomingWebhookBot);