azure_functions/send_grid/
google_analytics.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents the ability to enable tracking provided by Google Analytics.
4#[derive(Debug, Default, Clone, Serialize, Deserialize)]
5pub struct GoogleAnalytics {
6    /// The value indicating whether this setting is enabled.
7    pub enable: bool,
8    /// The name of the referrer source.
9    #[serde(rename = "utm_source")]
10    pub source: String,
11    /// The name of the marketing medium.
12    #[serde(rename = "utm_medium")]
13    pub medium: String,
14    /// The identification of any paid keywords.
15    #[serde(rename = "utm_term")]
16    pub term: String,
17    /// The differentiation of your campaign from advertisements.
18    #[serde(rename = "utm_content")]
19    pub content: String,
20    /// The name of the campaign.
21    #[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}