azure_functions/send_grid/
unsubscribe_group.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Default, Clone, Serialize, Deserialize)]
5pub struct UnsubscribeGroup {
6 pub group_id: i32,
8 #[serde(skip_serializing_if = "Vec::is_empty")]
11 pub groups_to_display: Vec<i32>,
12}
13
14#[cfg(test)]
15mod tests {
16 use super::*;
17 use serde_json::to_string;
18
19 #[test]
20 fn it_serializes_to_json() {
21 let json = to_string(&UnsubscribeGroup {
22 group_id: 12345,
23 groups_to_display: Vec::new(),
24 })
25 .unwrap();
26
27 assert_eq!(json, r#"{"group_id":12345}"#);
28
29 let json = to_string(&UnsubscribeGroup {
30 group_id: 12345,
31 groups_to_display: vec![1, 2, 3, 4, 5],
32 })
33 .unwrap();
34
35 assert_eq!(
36 json,
37 r#"{"group_id":12345,"groups_to_display":[1,2,3,4,5]}"#
38 );
39 }
40}