From 34c47ac529e17193847e8d1634ba3fbd50120a12 Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 29 May 2026 22:55:32 -0400 Subject: [PATCH] Organization (#11) Reviewed-on: http://git.kundeng.us/phoenix/textsender-models/pulls/11 --- src/user/mod.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/user/mod.rs b/src/user/mod.rs index 5a25302..9f883d6 100644 --- a/src/user/mod.rs +++ b/src/user/mod.rs @@ -28,6 +28,14 @@ pub struct ServiceUser { pub last_login: Option, } +#[derive(Clone, Debug, Default, Deserialize, Serialize)] +pub struct Organization { + pub id: uuid::Uuid, + pub name: String, + #[serde(with = "time::serde::rfc3339::option")] + pub created: Option, +} + #[derive(Clone, Debug, Default, Deserialize, Serialize)] pub struct UserLoginHistory { pub id: uuid::Uuid, @@ -51,7 +59,9 @@ pub struct UserProfile { pub username: String, pub firstname: String, pub lastname: String, + #[serde(with = "time::serde::rfc3339::option")] pub created: Option, + #[serde(with = "time::serde::rfc3339::option")] pub last_login: Option, } @@ -66,3 +76,27 @@ pub fn init_user_profile(usr: &User) -> UserProfile { last_login: usr.last_login, } } + +#[cfg(test)] +mod tests { + #[test] + fn test_init_user_profile() { + let usr = super::User { + id: uuid::Uuid::new_v4(), + phone_number: String::from("+12308438462"), + username: String::from("Cowboy99"), + password: String::from("238n7cyr2q89d3xhe2"), + firstname: String::from("BillyBob"), + lastname: String::from("Jones"), + created: Some(time::OffsetDateTime::now_utc()), + last_login: Some(time::OffsetDateTime::now_utc()), + ..Default::default() + }; + + let profile = super::init_user_profile(&usr); + assert_eq!( + usr.phone_number, profile.phone_number, + "Phone numbers are not equal" + ); + } +}