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};

/// Represents details about a realm playground.
///
/// 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 RealmPlayground {
    #[serde(skip_serializing_if = "Option::is_none")]
    id: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pygments_language: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    url_template: Option<String>,
}

impl RealmPlayground {
    /// Object containing details about a realm playground.
    pub const fn new() -> Self {
        Self {
            id: None,
            name: None,
            pygments_language: None,
            url_template: None,
        }
    }
}

field_access! {
    RealmPlayground {
        /// The unique ID for the realm playground.
        id: option { u64 },
    }
}

field_access! {
    RealmPlayground {
        /// The user-visible display name of the playground.
        ///
        /// Clients should display this in UI for picking which playground to open a code block in,
        /// to differentiate between multiple configured playground options for a given pygments language.
        ///
        /// **Changes**: New in Zulip 4.0 (feature level 49).
        name: option_cow_deref { str, String },
        /// The name of the Pygments language lexer for that programming language.
        pygments_language: option_cow_deref { str, String },
        /// The [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.html) compliant URL template for the playground.
        ///
        /// The template contains exactly one variable named `code`, which determines how the extracted code should be substituted in the playground URL.
        ///
        /// **Changes**: New in Zulip 8.0 (feature level 196). This replaced the `url_prefix` parameter, which was used to construct URLs by just concatenating url_prefix and code.
        url_template: option_cow_deref { str, String },
    }
}

impl_default!(RealmPlayground);
impl_display!(RealmPlayground);