cal_core/rest/
user.rs

1// File: cal-core/src/rest/user.rs
2
3use crate::client::Client;
4use crate::{AccountLite, RecordReference, DDI};
5use serde::{Deserialize, Serialize};
6#[cfg(feature = "openapi")]
7use utoipa::ToSchema;
8
9/// Request for user details
10#[derive(Debug, Clone, Serialize, Deserialize)]
11#[cfg_attr(feature = "openapi", derive(ToSchema))]
12#[cfg_attr(feature = "openapi", schema(
13    title ="Request to fetch user details using authentication token",
14    example = json!({
15        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
16    })
17))]
18#[serde(rename_all = "camelCase")]
19pub struct UserDetailsRequest {
20    /// Authentication token
21    #[cfg_attr(feature = "openapi", schema(example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."))]
22    pub token: String,
23}
24
25/// Detailed user information response
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(rename_all = "camelCase")]
28#[cfg_attr(feature = "openapi", derive(ToSchema))]
29#[cfg_attr(feature = "openapi", schema(
30    title ="Comprehensive user details including account, device, and agent information",
31    example = json!({
32        "agent_name": "John Doe",
33        "email": "john.doe@example.com",
34        "first_name": "John",
35        "last_name": "Doe",
36        "groups": ["sales", "support"],
37        "account_name": "Acme Corporation",
38        "customers": [
39            {"id": "cust_1", "name": "Customer 1"},
40            {"id": "cust_2", "name": "Customer 2"}
41        ],
42        "softphone_enabled": true,
43        "agent_status": "available",
44        "is_registered": true,
45        "is_available": true
46    })
47))]
48pub struct UserDetailsResponse {
49    /// Agent display name
50    #[cfg_attr(feature = "openapi", schema(example = "John Doe"))]
51    pub agent_name: Option<String>,
52
53    /// User's email address
54    #[cfg_attr(feature = "openapi", schema(example = "john.doe@example.com"))]
55    pub email: String,
56
57    /// User's first name
58    #[cfg_attr(feature = "openapi", schema(example = "John"))]
59    pub first_name: String,
60
61    /// User's last name
62    #[cfg_attr(feature = "openapi", schema(example = "Doe"))]
63    pub last_name: String,
64
65    /// Groups the user belongs to
66    #[cfg_attr(feature = "openapi", schema(example = json!(["sales", "support", "admin"])))]
67    pub groups: Vec<String>,
68
69    /// Name of the user's account
70    #[cfg_attr(feature = "openapi", schema(example = "Acme Corporation"))]
71    pub account_name: String,
72
73    /// List of customers the user has access to
74    pub customers: Vec<RecordReference>,
75
76    /// Agent-specific settings
77    pub agent_settings: Option<crate::AgentSettings>,
78
79    /// Whether softphone is enabled
80    #[cfg_attr(feature = "openapi", schema(example = true))]
81    pub softphone_enabled: bool,
82
83    /// Current agent status (e.g., available, busy, offline)
84    #[cfg_attr(feature = "openapi", schema(example = "available"))]
85    pub agent_status: Option<String>,
86
87    /// Whether the agent is registered
88    #[cfg_attr(feature = "openapi", schema(example = true))]
89    pub is_registered: Option<bool>,
90
91    /// Whether the agent is available for calls
92    #[cfg_attr(feature = "openapi", schema(example = true))]
93    pub is_available: Option<bool>,
94
95    /// Lite account information
96    pub account: Option<AccountLite>,
97
98    /// User's device information
99    pub device: Option<Client>,
100
101    /// User's DDI (Direct Dial-In) number
102    pub ddi: Option<DDI>,
103
104    /// User's WhatsApp business number
105    pub whatsapp: Option<DDI>,
106}