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 the properties of an authentication method for the organization - its enabled status and availability for use by the organization.
///
/// 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 RealmAuthenticationMethod {
    #[serde(skip_serializing_if = "Option::is_none")]
    enabled: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    available: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    unavailable_reason: Option<String>,
}

impl RealmAuthenticationMethod {
    /// Creates a new [RealmAuthenticationMethod].
    pub const fn new() -> Self {
        Self {
            enabled: None,
            available: None,
            unavailable_reason: None,
        }
    }
}

field_access! {
    RealmAuthenticationMethod {
        /// Boolean describing whether the authentication method (i.e. its key) is enabled in this organization.
        enabled: option { bool },
        /// Boolean describing whether the authentication method is available for use. If false, the organization is not eligible to enable the authentication method.
        available: option { bool },
    }
}

field_access! {
    RealmAuthenticationMethod {
        /// Reason why the authentication method is unavailable.
        ///
        /// This field is optional and is only present when 'available' is false.
        unavailable_reason: option_cow_deref { str, String },
    }
}

impl_default!(RealmAuthenticationMethod);
impl_display!(RealmAuthenticationMethod);