zulip-api 0.0.8

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

/// Represents extra configuration details for the bot.
///
/// The fields in the object depend on the type of 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)]
#[serde(untagged)]
pub enum BotService {
    OutgoingWebhook(BotServiceOutgoingWebhook),
    Embedded(BotServiceEmbedded),
}

impl BotService {
    /// Creates a new [BotService].
    pub const fn new() -> Self {
        Self::OutgoingWebhook(BotServiceOutgoingWebhook::new())
    }
}

impl Default for BotService {
    fn default() -> Self {
        Self::new()
    }
}

/// Represents when the bot is an outgoing webhook.
///
/// 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 BotServiceOutgoingWebhook {
    /// The URL the outgoing webhook is configured to post to.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub base_url: Option<String>,
    /// A unique token that the third-party service can use to confirm that the request is indeed coming from Zulip.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub token: Option<String>,
    /// An integer indicating what format requests are posted in:  - 1 = Zulip's native outgoing webhook format. - 2 = Emulate the Slack outgoing webhook format.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interface: Option<OutgoingWebhookInterface>,
}

/// Represents An integer indicating what format requests are posted in
///
/// 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).
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize_repr, Serialize_repr)]
pub enum OutgoingWebhookInterface {
    /// Zulip's native outgoing webhook format
    Native = 1,
    /// Emulate the Slack outgoing webhook format.
    EmulateSlack = 2,
}

impl BotServiceOutgoingWebhook {
    /// When the bot is an outgoing webhook.
    pub const fn new() -> Self {
        Self {
            base_url: None,
            token: None,
            interface: None,
        }
    }
}

impl Default for BotServiceOutgoingWebhook {
    fn default() -> Self {
        Self::new()
    }
}

/// Represents when the bot is an embedded 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 BotServiceEmbedded {
    /// The name of the bot.
    #[serde(rename = "service_name", skip_serializing_if = "Option::is_none")]
    pub service_name: Option<String>,
    /// A dictionary of string key/value pairs, which describe the configuration for the bot. These are usually details like API keys, and are unique to the integration/bot. Can be an empty dictionary.
    #[serde(rename = "config_data", skip_serializing_if = "Option::is_none")]
    pub config_data: Option<std::collections::HashMap<String, String>>,
}

impl BotServiceEmbedded {
    /// Creates a new [BotServiceEmbedded].
    pub const fn new() -> Self {
        Self {
            service_name: None,
            config_data: None,
        }
    }
}

impl Default for BotServiceEmbedded {
    fn default() -> Self {
        Self::new()
    }
}