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

/// Represents the status details of a user with the key of the object being the ID of the user.
///
/// 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 UserStatus {
    #[serde(skip_serializing_if = "Option::is_none")]
    away: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    status_text: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    emoji_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    emoji_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    reaction_type: Option<ReactionType>,
}

impl UserStatus {
    /// Creates a new [UserStatus].
    pub const fn new() -> Self {
        Self {
            away: None,
            status_text: None,
            emoji_name: None,
            emoji_code: None,
            reaction_type: None,
        }
    }
}

field_access! {
    UserStatus {
        /// If present, the user has marked themself \"away\".
        ///
        /// **Changes**: Deprecated in Zulip 6.0 (feature level 148);
        /// starting with that feature level,
        /// `away` is a legacy way to access the user's `presence_enabled` setting,
        /// with `away = !presence_enabled`.
        ///
        /// To be removed in a future release.
        away: option { bool },
        /// If present, a string indicating the type of emoji.
        reaction_type: option { ReactionType },
    }
}

field_access! {
    UserStatus {
        /// If present, the text content of the user's status message.
        status_text: option_cow_deref { str, String },
        /// If present, the name for the emoji to associate with the user's status.  **Changes**: New in Zulip 5.0 (feature level 86).
        emoji_name: option_cow_deref { str, String },
        /// If present, a unique identifier, defining the specific emoji codepoint requested, within the namespace of the `reaction_type`.
        ///
        /// **Changes**: New in Zulip 5.0 (feature level 86).
        emoji_code: option_cow_deref { str, String },
    }
}

impl_default!(UserStatus);
impl_display!(UserStatus);