notionrs_schema/object/database/
files.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Deserialize, Serialize, Debug, Default, Clone, PartialEq, Eq, notionrs_macro::Setter)]
4pub struct DatabaseFilesProperty {
5    /// Property Identifier
6    #[serde(skip_serializing)]
7    pub id: Option<String>,
8
9    /// Modify the value of this field when updating the column name of the property.
10    #[serde(skip_serializing)]
11    pub name: String,
12
13    /// Although it is not explicitly stated in the official documentation,
14    /// you can add a description to the property by specifying this.
15    #[serde(skip_serializing)]
16    pub description: Option<String>,
17
18    /// An empty object (`{}`)
19    pub files: std::collections::HashMap<(), ()>,
20}
21
22// # --------------------------------------------------------------------------------
23//
24// unit test
25//
26// # --------------------------------------------------------------------------------
27#[cfg(test)]
28mod unit_tests {
29
30    use super::*;
31
32    #[test]
33    fn deserialize_database_files_property() {
34        let json_data = r#"
35        {
36            "id": "pb%3E%5B",
37            "name": "Product image",
38            "type": "files",
39            "files": {}
40        }
41        "#;
42
43        let files = serde_json::from_str::<DatabaseFilesProperty>(json_data).unwrap();
44
45        assert_eq!(files.id, Some("pb%3E%5B".to_string()));
46        assert_eq!(files.name, "Product image");
47        assert_eq!(files.files, std::collections::HashMap::new());
48    }
49}