Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sendgrid/helpers/mail/spam_check.py: 31%
44 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1from .spam_threshold import SpamThreshold
2from .spam_url import SpamUrl
5class SpamCheck(object):
6 """This allows you to test the content of your email for spam."""
8 def __init__(self, enable=None, threshold=None, post_to_url=None):
9 """Create a SpamCheck to test the content of your email for spam.
11 :param enable: If this setting is applied.
12 :type enable: boolean, optional
13 :param threshold: Spam qualification threshold, from 1 to 10 (strict).
14 :type threshold: int, optional
15 :param post_to_url: Inbound Parse URL to send a copy of your email.
16 :type post_to_url: string, optional
17 """
18 self._enable = None
19 self._threshold = None
20 self._post_to_url = None
22 if enable is not None:
23 self.enable = enable
24 if threshold is not None:
25 self.threshold = threshold
26 if post_to_url is not None:
27 self.post_to_url = post_to_url
29 @property
30 def enable(self):
31 """Indicates if this setting is enabled.
33 :rtype: boolean
34 """
35 return self._enable
37 @enable.setter
38 def enable(self, value):
39 """Indicates if this setting is enabled.
41 :param value: Indicates if this setting is enabled.
42 :type value: boolean
43 """
44 self._enable = value
46 @property
47 def threshold(self):
48 """Threshold used to determine if your content qualifies as spam.
49 On a scale from 1 to 10, with 10 being most strict, or most likely to
50 be considered as spam.
52 :rtype: int
53 """
54 return self._threshold
56 @threshold.setter
57 def threshold(self, value):
58 """Threshold used to determine if your content qualifies as spam.
59 On a scale from 1 to 10, with 10 being most strict, or most likely to
60 be considered as spam.
62 :param value: Threshold used to determine if your content qualifies as
63 spam.
64 On a scale from 1 to 10, with 10 being most strict, or
65 most likely to be considered as spam.
66 :type value: int
67 """
68 if isinstance(value, SpamThreshold):
69 self._threshold = value
70 else:
71 self._threshold = SpamThreshold(value)
73 @property
74 def post_to_url(self):
75 """An Inbound Parse URL to send a copy of your email.
76 If defined, a copy of your email and its spam report will be sent here.
78 :rtype: string
79 """
80 return self._post_to_url
82 @post_to_url.setter
83 def post_to_url(self, value):
84 """An Inbound Parse URL to send a copy of your email.
85 If defined, a copy of your email and its spam report will be sent here.
87 :param value: An Inbound Parse URL to send a copy of your email.
88 If defined, a copy of your email and its spam report will be sent here.
89 :type value: string
90 """
91 if isinstance(value, SpamUrl):
92 self._post_to_url = value
93 else:
94 self._post_to_url = SpamUrl(value)
96 def get(self):
97 """
98 Get a JSON-ready representation of this SpamCheck.
100 :returns: This SpamCheck, ready for use in a request body.
101 :rtype: dict
102 """
103 spam_check = {}
104 if self.enable is not None:
105 spam_check["enable"] = self.enable
107 if self.threshold is not None:
108 spam_check["threshold"] = self.threshold.get()
110 if self.post_to_url is not None:
111 spam_check["post_to_url"] = self.post_to_url.get()
112 return spam_check