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 of unread one-on-one direct messages with a specific user.
///
/// Note that it is possible for a message that the current user sent to the specified user to be marked as unread and thus appear here.
///
/// 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 UnreadMsgsPm {
    /// The user ID of the other participant in this one-on-one direct message conversation. Will be the current user's ID for messages that they sent in a one-on-one direct message conversation with themself.  **Changes**: New in Zulip 5.0 (feature level 119), replacing the less clearly named `sender_id` field.
    #[serde(skip_serializing_if = "Option::is_none")]
    other_user_id: Option<u64>,
    /// Old name for the `other_user_id` field. Clients should access this field in Zulip server versions that do not yet support `other_user_id`.  **Changes**: Deprecated in Zulip 5.0 (feature level 119). We expect to provide a next version of the full `unread_msgs` API before removing this legacy name.
    #[serde(skip_serializing_if = "Option::is_none")]
    sender_id: Option<u64>,
    /// The message IDs of the recent unread direct messages sent by either user in this one-on-one direct message conversation, sorted in ascending order.
    #[serde(skip_serializing_if = "Option::is_none")]
    unread_message_ids: Option<Vec<u64>>,
}

impl UnreadMsgsPm {
    /// Creates a new [UnreadMsgsPm].
    pub fn new() -> Self {
        Self {
            other_user_id: None,
            sender_id: None,
            unread_message_ids: None,
        }
    }
}

field_access! {
    UnreadMsgsPm {
        /// The user ID of the other participant in this one-on-one direct message conversation.
        ///
        /// Will be the current user's ID for messages that they sent in a one-on-one direct message conversation with themself.
        ///
        /// **Changes**: New in Zulip 5.0 (feature level 119), replacing the less clearly named `sender_id` field.
        other_user_id: option { u64 },
        /// Old name for the `other_user_id` field.
        ///
        /// Clients should access this field in Zulip server versions that do not yet support `other_user_id`.
        ///
        /// **Changes**: Deprecated in Zulip 5.0 (feature level 119). We expect to provide a next version of the full `unread_msgs` API before removing this legacy name.
        sender_id: option { u64 },
    }
}

field_access! {
    UnreadMsgsPm {
        /// The message IDs of the recent unread direct messages sent by either user in this one-on-one direct message conversation, sorted in ascending order.
        unread_message_ids: option_cow_deref { [u64], Vec<u64> },
    }
}

impl_default!(UnreadMsgsPm);
impl_display!(UnreadMsgsPm);