use serde::{Deserialize, Serialize};
use super::common::{Gid, ResourceRef, StatusColor, UserRef};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct StatusUpdate {
pub gid: Gid,
pub title: Option<String>,
pub text: Option<String>,
pub html_text: Option<String>,
pub status_type: Option<StatusColor>,
pub created_at: Option<String>,
pub created_by: Option<UserRef>,
pub parent: Option<ResourceRef>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct StatusUpdateRef {
pub gid: Gid,
pub title: Option<String>,
pub text: Option<String>,
pub status_type: Option<StatusColor>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_deserialize_status_update() {
let json = r#"{
"gid": "123",
"title": "On Track",
"text": "Everything is going well",
"status_type": "green",
"created_at": "2024-01-15T10:30:00.000Z"
}"#;
let status: StatusUpdate = serde_json::from_str(json).unwrap();
assert_eq!(status.gid, "123");
assert_eq!(status.title, Some("On Track".to_string()));
assert_eq!(status.status_type, Some(StatusColor::Green));
}
#[test]
fn test_deserialize_status_update_ref() {
let json = r#"{
"gid": "456",
"title": "At Risk",
"status_type": "yellow"
}"#;
let status_ref: StatusUpdateRef = serde_json::from_str(json).unwrap();
assert_eq!(status_ref.gid, "456");
assert_eq!(status_ref.status_type, Some(StatusColor::Yellow));
}
}