azure_functions/send_grid/
open_tracking.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents the ability to track whether a recipient opened an email message.
4///
5/// Open tracking includes a single pixel image in the body of the content to determine when the email was opened.
6#[derive(Debug, Default, Clone, Serialize, Deserialize)]
7pub struct OpenTracking {
8    /// The value indicating whether this setting is enabled.
9    pub enable: bool,
10    /// The substitution tag that can be used to control the desired location of the tracking pixel in the email message.
11    ///
12    /// The tag will be replaced by the open tracking pixel.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub substitution_tag: Option<String>,
15}
16
17#[cfg(test)]
18mod tests {
19    use super::*;
20    use serde_json::to_string;
21
22    #[test]
23    fn it_serializes_to_json() {
24        let json = to_string(&OpenTracking {
25            enable: true,
26            substitution_tag: Some("foo".to_owned()),
27        })
28        .unwrap();
29
30        assert_eq!(json, r#"{"enable":true,"substitution_tag":"foo"}"#);
31    }
32}