azure_functions/send_grid/
google_analytics.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Default, Clone, Serialize, Deserialize)]
5pub struct GoogleAnalytics {
6 pub enable: bool,
8 #[serde(rename = "utm_source")]
10 pub source: String,
11 #[serde(rename = "utm_medium")]
13 pub medium: String,
14 #[serde(rename = "utm_term")]
16 pub term: String,
17 #[serde(rename = "utm_content")]
19 pub content: String,
20 #[serde(rename = "utm_campaign")]
22 pub campaign: String,
23}
24
25#[cfg(test)]
26mod tests {
27 use super::*;
28 use serde_json::to_string;
29
30 #[test]
31 fn it_serializes_to_json() {
32 let json = to_string(&GoogleAnalytics {
33 enable: true,
34 source: "foo".to_owned(),
35 medium: "bar".to_owned(),
36 term: "baz".to_owned(),
37 content: "jam".to_owned(),
38 campaign: "cake".to_owned(),
39 })
40 .unwrap();
41
42 assert_eq!(
43 json,
44 r#"{"enable":true,"utm_source":"foo","utm_medium":"bar","utm_term":"baz","utm_content":"jam","utm_campaign":"cake"}"#
45 );
46 }
47}