artifacts/models/
log_schema.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
5#[cfg_attr(feature = "specta", derive(specta::Type))]
6pub struct LogSchema {
7    /// Character name.
8    #[serde(rename = "character")]
9    pub character: String,
10    /// Account character.
11    #[serde(rename = "account")]
12    pub account: String,
13    /// Type of action.
14    #[serde(rename = "type")]
15    pub r#type: models::LogType,
16    /// Description of action.
17    #[serde(rename = "description")]
18    pub description: String,
19    #[serde(rename = "content", deserialize_with = "Option::deserialize")]
20    #[cfg_attr(feature = "specta", specta(type = Option<specta_util::Unknown>))]
21    pub content: Option<serde_json::Value>,
22    /// Cooldown in seconds.
23    #[serde(rename = "cooldown")]
24    pub cooldown: i32,
25    /// Datetime of cooldown expiration.
26    #[serde(
27        rename = "cooldown_expiration",
28        skip_serializing_if = "Option::is_none"
29    )]
30    pub cooldown_expiration: Option<String>,
31    /// Datetime of creation.
32    #[serde(rename = "created_at")]
33    pub created_at: String,
34}
35
36impl LogSchema {
37    pub fn new(
38        character: String,
39        account: String,
40        r#type: models::LogType,
41        description: String,
42        content: Option<serde_json::Value>,
43        cooldown: i32,
44        created_at: String,
45    ) -> LogSchema {
46        LogSchema {
47            character,
48            account,
49            r#type,
50            description,
51            content,
52            cooldown,
53            cooldown_expiration: None,
54            created_at,
55        }
56    }
57}