smbcloud_model/
app_auth.rs1use crate::ar_date_format;
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4use tsync::tsync;
5
6#[derive(Serialize, Deserialize, Debug, Clone)]
7pub struct AuthApp {
8 pub id: String,
9 pub secret: Option<String>,
10 pub name: String,
11 #[serde(with = "ar_date_format")]
12 pub created_at: DateTime<Utc>,
13 #[serde(with = "ar_date_format")]
14 pub updated_at: DateTime<Utc>,
15}
16
17#[derive(Serialize, Deserialize, Debug, Clone)]
18pub struct AuthAppCreate {
19 pub name: String,
20 pub description: String,
21}
22
23#[derive(Serialize, Deserialize, Debug, Clone)]
31#[tsync]
32pub struct AuthAppClient {
33 pub id: i64,
34 pub client_id: String,
35 pub name: String,
36 pub redirect_uris: String,
37 pub confidential: bool,
38 pub auth_app_id: String,
39 #[serde(with = "ar_date_format")]
40 pub created_at: DateTime<Utc>,
41 #[serde(with = "ar_date_format")]
42 pub updated_at: DateTime<Utc>,
43}
44
45#[derive(Serialize, Deserialize, Debug, Clone)]
49#[tsync]
50pub struct AuthAppClientCreate {
51 pub name: String,
52 pub redirect_uris: String,
53}
54
55#[cfg(test)]
56mod tests {
57 use super::*;
58 use serde_json::json;
59 #[test]
60 fn test_auth_app_create() {
61 let auth_app_create = AuthAppCreate {
62 name: "test".to_owned(),
63 description: "test".to_owned(),
64 };
65 let json = json!({
66 "name": "test",
67 "description": "test",
68 });
69 assert_eq!(serde_json::to_value(auth_app_create).unwrap(), json);
70 }
71}