azure_functions/send_grid/spam_check.rs
1use serde::{Deserialize, Serialize};
2
3/// Represents the ability to test the email message for spam content.
4#[derive(Debug, Default, Clone, Serialize, Deserialize)]
5pub struct SpamCheck {
6 /// The value indicating whether this setting is enabled.
7 pub enable: bool,
8 /// The threshold used to determine if your content qualifies as spam on a scale from 1 to 10.
9 ///
10 /// A value of 10 is the most strict or most likely to be considered as spam.
11 pub threshold: i32,
12 /// The inbound post URL that you would like a copy of your email, along with the spam report, sent to.
13 ///
14 /// The URL must start with `http://` or `https://`.
15 pub post_to_url: String,
16}
17
18#[cfg(test)]
19mod tests {
20 use super::*;
21 use serde_json::to_string;
22
23 #[test]
24 fn it_serializes_to_json() {
25 let json = to_string(&SpamCheck {
26 enable: true,
27 threshold: 7,
28 post_to_url: "https://example.com".to_owned(),
29 })
30 .unwrap();
31
32 assert_eq!(
33 json,
34 r#"{"enable":true,"threshold":7,"post_to_url":"https://example.com"}"#
35 );
36 }
37}