openlark_workflow/v2/section/
models.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Default)]
7pub struct CreateSectionBody {
8 pub summary: String,
10
11 #[serde(skip_serializing_if = "Option::is_none")]
13 pub description: Option<String>,
14}
15
16#[derive(Debug, Clone, Serialize, Default)]
18pub struct UpdateSectionBody {
19 #[serde(skip_serializing_if = "Option::is_none")]
21 pub summary: Option<String>,
22
23 #[serde(skip_serializing_if = "Option::is_none")]
25 pub description: Option<String>,
26}
27
28#[derive(Debug, Clone, Deserialize)]
30pub struct CreateSectionResponse {
31 pub section_guid: String,
33
34 pub summary: String,
36
37 #[serde(default)]
39 pub description: Option<String>,
40
41 pub created_at: String,
43
44 pub updated_at: String,
46}
47
48#[derive(Debug, Clone, Deserialize)]
50pub struct GetSectionResponse {
51 pub section_guid: String,
53
54 pub summary: String,
56
57 #[serde(default)]
59 pub description: Option<String>,
60
61 pub created_at: String,
63
64 pub updated_at: String,
66}
67
68#[derive(Debug, Clone, Deserialize)]
70pub struct UpdateSectionResponse {
71 pub section_guid: String,
73
74 pub summary: String,
76
77 #[serde(default)]
79 pub description: Option<String>,
80
81 pub updated_at: String,
83}
84
85#[derive(Debug, Clone, Deserialize)]
87pub struct DeleteSectionResponse {
88 pub success: bool,
90
91 pub section_guid: String,
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
97pub struct SectionItem {
98 pub section_guid: String,
100
101 pub summary: String,
103
104 #[serde(default)]
106 pub description: Option<String>,
107
108 pub created_at: String,
110
111 pub updated_at: String,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
117pub struct ListSectionsResponse {
118 #[serde(default)]
120 pub has_more: bool,
121
122 #[serde(skip_serializing_if = "Option::is_none")]
124 pub page_token: Option<String>,
125
126 #[serde(skip_serializing_if = "Option::is_none")]
128 pub total: Option<i32>,
129
130 #[serde(default)]
132 pub items: Vec<SectionItem>,
133}
134
135#[cfg(test)]
136#[allow(unused_imports)]
137mod tests {
138
139 #[test]
140 fn test_serialization_roundtrip() {
141 let json = r#"{"test": "value"}"#;
143 assert!(serde_json::from_str::<serde_json::Value>(json).is_ok());
144 }
145
146 #[test]
147 fn test_deserialization_from_json() {
148 let json = r#"{"field": "data"}"#;
150 let value: serde_json::Value = serde_json::from_str(json).unwrap();
151 assert_eq!(value["field"], "data");
152 }
153}