use serde::{Deserialize, Serialize};
use super::common::Gid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct User {
pub gid: Gid,
pub name: String,
pub email: Option<String>,
pub photo: Option<UserPhoto>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct UserPhoto {
pub image_21x21: Option<String>,
pub image_27x27: Option<String>,
pub image_36x36: Option<String>,
pub image_60x60: Option<String>,
pub image_128x128: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct FavoriteItem {
pub gid: Gid,
pub resource_type: String,
pub name: Option<String>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_deserialize_user() {
let json = r#"{
"gid": "123",
"name": "Test User",
"email": "test@example.com"
}"#;
let user: User = serde_json::from_str(json).unwrap();
assert_eq!(user.gid, "123");
assert_eq!(user.name, "Test User");
assert_eq!(user.email, Some("test@example.com".to_string()));
}
#[test]
fn test_deserialize_favorite_item() {
let json = r#"{
"gid": "456",
"resource_type": "project",
"name": "My Project"
}"#;
let item: FavoriteItem = serde_json::from_str(json).unwrap();
assert_eq!(item.gid, "456");
assert_eq!(item.resource_type, "project");
assert_eq!(item.name, Some("My Project".to_string()));
}
}