smbcloud_model/
app_auth.rs

1use crate::ar_date_format;
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Debug)]
6pub struct AuthApp {
7    pub id: String,
8    pub secret: Option<String>,
9    pub name: String,
10    #[serde(with = "ar_date_format")]
11    pub created_at: DateTime<Utc>,
12    #[serde(with = "ar_date_format")]
13    pub updated_at: DateTime<Utc>,
14}
15
16#[derive(Serialize, Deserialize, Debug)]
17pub struct AuthAppCreate {
18    pub name: String,
19    pub description: String,
20}
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25    use serde_json::json;
26    #[test]
27    fn test_auth_app_create() {
28        let auth_app_create = AuthAppCreate {
29            name: "test".to_owned(),
30            description: "test".to_owned(),
31        };
32        let json = json!({
33            "name": "test",
34            "description": "test",
35        });
36        assert_eq!(serde_json::to_value(auth_app_create).unwrap(), json);
37    }
38}