cal-core 0.2.158

Callable core lib
Documentation
// File: cal-core/src/rest/user.rs

use crate::client::Client;
use crate::{AccountLite, RecordReference, DDI};
use serde::{Deserialize, Serialize};
#[cfg(feature = "openapi")]
use utoipa::ToSchema;

/// Request for user details
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
#[cfg_attr(feature = "openapi", schema(
    title ="Request to fetch user details using authentication token",
    example = json!({
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
    })
))]
#[serde(rename_all = "camelCase")]
pub struct UserDetailsRequest {
    /// Authentication token
    #[cfg_attr(feature = "openapi", schema(example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."))]
    pub token: String,
}

/// Detailed user information response
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
#[cfg_attr(feature = "openapi", schema(
    title ="Comprehensive user details including account, device, and agent information",
    example = json!({
        "agent_name": "John Doe",
        "email": "john.doe@example.com",
        "first_name": "John",
        "last_name": "Doe",
        "groups": ["sales", "support"],
        "account_name": "Acme Corporation",
        "customers": [
            {"id": "cust_1", "name": "Customer 1"},
            {"id": "cust_2", "name": "Customer 2"}
        ],
        "softphone_enabled": true,
        "agent_status": "available",
        "is_registered": true,
        "is_available": true
    })
))]
pub struct UserDetailsResponse {
    /// Agent display name
    #[cfg_attr(feature = "openapi", schema(example = "John Doe"))]
    pub agent_name: Option<String>,

    /// User's email address
    #[cfg_attr(feature = "openapi", schema(example = "john.doe@example.com"))]
    pub email: String,

    /// User's first name
    #[cfg_attr(feature = "openapi", schema(example = "John"))]
    pub first_name: String,

    /// User's last name
    #[cfg_attr(feature = "openapi", schema(example = "Doe"))]
    pub last_name: String,

    /// Groups the user belongs to
    #[cfg_attr(feature = "openapi", schema(example = json!(["sales", "support", "admin"])))]
    pub groups: Vec<String>,

    /// Name of the user's account
    #[cfg_attr(feature = "openapi", schema(example = "Acme Corporation"))]
    pub account_name: String,

    /// List of customers the user has access to
    pub customers: Vec<RecordReference>,

    /// Agent-specific settings
    pub agent_settings: Option<crate::AgentSettings>,

    /// Whether softphone is enabled
    #[cfg_attr(feature = "openapi", schema(example = true))]
    pub softphone_enabled: bool,

    /// Current agent status (e.g., available, busy, offline)
    #[cfg_attr(feature = "openapi", schema(example = "available"))]
    pub agent_status: Option<String>,

    /// Whether the agent is registered
    #[cfg_attr(feature = "openapi", schema(example = true))]
    pub is_registered: Option<bool>,

    /// Whether the agent is available for calls
    #[cfg_attr(feature = "openapi", schema(example = true))]
    pub is_available: Option<bool>,

    /// Lite account information
    pub account: Option<AccountLite>,

    /// User's device information
    pub device: Option<Client>,

    /// User's DDI (Direct Dial-In) number
    pub ddi: Option<DDI>,

    /// User's WhatsApp business number
    pub whatsapp: Option<DDI>,
}