Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sendgrid/helpers/mail/html_content.py: 39%
25 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 .content import Content
2from .validators import ValidateApiKey
5class HtmlContent(Content):
6 """HTML content to be included in your email."""
8 def __init__(self, content):
9 """Create an HtmlContent with the specified MIME type and content.
11 :param content: The HTML content.
12 :type content: string
13 """
14 self._content = None
15 self._validator = ValidateApiKey()
17 if content is not None:
18 self.content = content
20 @property
21 def mime_type(self):
22 """The MIME type for HTML content.
24 :rtype: string
25 """
26 return "text/html"
28 @property
29 def content(self):
30 """The actual HTML content.
32 :rtype: string
33 """
34 return self._content
36 @content.setter
37 def content(self, value):
38 """The actual HTML content.
40 :param value: The actual HTML content.
41 :type value: string
42 """
43 self._validator.validate_message_dict(value)
44 self._content = value
46 def get(self):
47 """
48 Get a JSON-ready representation of this HtmlContent.
50 :returns: This HtmlContent, ready for use in a request body.
51 :rtype: dict
52 """
53 content = {}
54 if self.mime_type is not None:
55 content["type"] = self.mime_type
57 if self.content is not None:
58 content["value"] = self.content
59 return content