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 the emoji with the specified ID. It has the following properties:
///
/// 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 RealmEmoji {
    #[serde(skip_serializing_if = "Option::is_none")]
    id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    source_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    still_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    deactivated: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    author_id: Option<u64>,
}

impl RealmEmoji {
    /// Creates a new [RealmEmoji].
    pub const fn new() -> Self {
        Self {
            id: None,
            name: None,
            source_url: None,
            still_url: None,
            deactivated: None,
            author_id: None,
        }
    }
}

field_access! {
    RealmEmoji {
        /// The ID for this emoji, same as the object's key.
        id: option_cow_deref { str, String },
        /// The user-friendly name for this emoji.
        ///
        /// Users in the organization can use this emoji by writing this name between colons (`:name :`).
        name: option_cow_deref { str, String },
        /// The path relative to the organization's URL where the emoji's image can be found.
        source_url: option_cow_deref { str, String },
        /// Only non-null when the emoji's image is animated.
        ///
        /// The path relative to the organization's URL where a still (not animated) version of the emoji can be found.
        /// (This is currently always the first frame of the animation).
        ///
        /// This is useful for clients to display the emoji in contexts where continuously animating it would be a bad user experience (e.g. because it would be distracting).
        ///
        /// **Changes**: New in Zulip 5.0 (added as optional field in feature level 97 and then made mandatory, but nullable, in feature level 113).
        still_url: option_cow_deref { str, String },
    }
}

field_access! {
    RealmEmoji {
        /// Whether the emoji has been deactivated or not.
        deactivated: option { bool },
        /// The user ID of the user who uploaded the custom emoji.
        ///
        /// Will be `null` if the uploader is unknown.
        ///
        /// **Changes**: New in Zulip 3.0 (feature level 7). Previously was accessible via an `author` object with an `id` field.
        author_id: option { u64 },
    }
}

impl_default!(RealmEmoji);
impl_display!(RealmEmoji);