azure_functions/send_grid/
subscription_tracking.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents the ability to insert a subscription management link at the bottom of the text and html bodies of email messages.
4///
5/// If you would like to specify the location of the link within your email, use `substitution_tag`.
6#[derive(Debug, Default, Clone, Serialize, Deserialize)]
7pub struct SubscriptionTracking {
8    /// The value indicating whether this setting is enabled.
9    pub enable: bool,
10    /// The text to be appended to the email, with the subscription tracking link.
11    pub text: String,
12    /// The HTML to be appended to the email, with the subscription tracking link.
13    pub html: String,
14    /// The tag that will be replaced with the unsubscribe URL.
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub substitution_tag: Option<String>,
17}
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22    use serde_json::to_string;
23
24    #[test]
25    fn it_serializes_to_json() {
26        let json = to_string(&SubscriptionTracking {
27            enable: true,
28            text: "foo".to_owned(),
29            html: "bar".to_owned(),
30            substitution_tag: Some("baz".to_owned()),
31        })
32        .unwrap();
33
34        assert_eq!(
35            json,
36            r#"{"enable":true,"text":"foo","html":"bar","substitution_tag":"baz"}"#
37        );
38    }
39}