notionrs_schema/object/database/
checkbox.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Deserialize, Serialize, Debug, Default, Clone, PartialEq, Eq, notionrs_macro::Setter)]
4pub struct DatabaseCheckboxProperty {
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 checkbox: 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_checkbox_property() {
34        let json_data = r#"
35        {
36            "id": "XjE%60",
37            "name": "Checkbox",
38            "type": "checkbox",
39            "checkbox": {}
40        }
41        "#;
42
43        let checkbox = serde_json::from_str::<DatabaseCheckboxProperty>(json_data).unwrap();
44
45        assert_eq!(checkbox.id, Some("XjE%60".to_string()));
46        assert_eq!(checkbox.name, "Checkbox");
47        assert_eq!(checkbox.checkbox, std::collections::HashMap::new());
48    }
49}