Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sendgrid/helpers/mail/plain_text_content.py: 39%

25 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1from .content import Content 

2from .validators import ValidateApiKey 

3 

4 

5class PlainTextContent(Content): 

6 """Plain text content to be included in your email. 

7 """ 

8 

9 def __init__(self, content): 

10 """Create a PlainTextContent with the specified MIME type and content. 

11 

12 :param content: The actual text content. 

13 :type content: string 

14 """ 

15 self._content = None 

16 self._validator = ValidateApiKey() 

17 

18 if content is not None: 

19 self.content = content 

20 

21 @property 

22 def mime_type(self): 

23 """The MIME type. 

24 

25 :rtype: string 

26 """ 

27 return "text/plain" 

28 

29 @property 

30 def content(self): 

31 """The actual text content. 

32 

33 :rtype: string 

34 """ 

35 return self._content 

36 

37 @content.setter 

38 def content(self, value): 

39 """The actual text content. 

40 

41 :param value: The actual text content. 

42 :type value: string 

43 """ 

44 self._validator.validate_message_dict(value) 

45 self._content = value 

46 

47 def get(self): 

48 """ 

49 Get a JSON-ready representation of this PlainTextContent. 

50 

51 :returns: This PlainTextContent, ready for use in a request body. 

52 :rtype: dict 

53 """ 

54 content = {} 

55 if self.mime_type is not None: 

56 content["type"] = self.mime_type 

57 

58 if self.content is not None: 

59 content["value"] = self.content 

60 return content