zulip-api 0.0.8

Client library for interacting with the Zulip API
Documentation
use serde::{Deserialize, Serialize};

use crate::{field_access, impl_default, impl_display, WebhookConfigOption, WebhookUrlOption};

/// Represents details of the incoming webhook bot.
///
/// Modified from `openapi-generator-cli` output:
///
/// ```shell,no_build,no_run
/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
/// ```
///
/// ```text
/// /*
/// * Zulip REST API
/// *
/// * Powerful open source group chat
/// *
/// * The version of the OpenAPI document: 1.0.0
/// *
/// * Generated by: https://openapi-generator.tech
/// */
/// ```
///
/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
///
/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RealmIncomingWebhookBot {
    #[serde(skip_serializing_if = "Option::is_none")]
    name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    display_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    all_event_types: Option<Vec<String>>,
    #[serde(rename = "config_options", skip_serializing_if = "Option::is_none")]
    config_options: Option<Vec<WebhookConfigOption>>,
    #[serde(rename = "url_options", skip_serializing_if = "Option::is_none")]
    url_options: Option<Vec<WebhookUrlOption>>,
}

impl RealmIncomingWebhookBot {
    /// Object containing details of the bot.
    pub const fn new() -> Self {
        Self {
            name: None,
            display_name: None,
            all_event_types: None,
            config_options: None,
            url_options: None,
        }
    }
}

field_access! {
    RealmIncomingWebhookBot {
        /// A machine-readable unique name identifying the integration, all-lower-case without spaces.
        name: option_cow_deref { str, String },
        /// A human-readable display name identifying the integration that this bot implements, intended to be used in menus for selecting which integration to create.
        ///
        /// **Changes**: New in Zulip 8.0 (feature level 207).
        display_name: option_cow_deref { str, String },
        /// For incoming webhook integrations that support the Zulip server filtering incoming events, the list of event types supported by it.
        ///
        /// A null value will be present if this incoming webhook integration doesn't support such filtering.
        ///
        /// **Changes**: New in Zulip 8.0 (feature level 207).
        all_event_types: option_cow_deref { [String], Vec<String> },
        /// An array of configuration options that can be set when creating a bot user for this incoming webhook integration.
        ///
        /// This is an unstable API. Please discuss in chat.zulip.org before using it.
        ///
        /// **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.
        /// 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),
        /// this field was named `config`, and was reserved for configuration data key-value pairs.
        config_options: option_cow_deref { [WebhookConfigOption], Vec<WebhookConfigOption> },
        /// An array of optional URL parameter options for the incoming webhook integration.
        ///
        /// In the web app, these are used when [generating a URL for an integration](https://zulip.com/help/generate-integration-url).
        ///
        /// This is an unstable API expected to be used only by the Zulip web app. Please discuss in chat.zulip.org before using it.
        ///
        /// **Changes**: New in Zulip 11.0 (feature level 403). Previously, these optional URL parameter options were included in the `config_options` object.
        url_options: option_cow_deref { [WebhookUrlOption], Vec<WebhookUrlOption> },
    }
}

impl_default!(RealmIncomingWebhookBot);
impl_display!(RealmIncomingWebhookBot);