Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/sendgrid/helpers/mail/amp_html_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 AmpHtmlContent(Content): 

6 """AMP HTML content to be included in your email.""" 

7 

8 def __init__(self, content): 

9 """Create an AMP HTML Content with the specified MIME type and content. 

10 

11 :param content: The AMP HTML content. 

12 :type content: string 

13 """ 

14 self._content = None 

15 self._validator = ValidateApiKey() 

16 

17 if content is not None: 

18 self.content = content 

19 

20 @property 

21 def mime_type(self): 

22 """The MIME type for AMP HTML content. 

23 

24 :rtype: string 

25 """ 

26 return "text/x-amp-html" 

27 

28 @property 

29 def content(self): 

30 """The actual AMP HTML content. 

31 

32 :rtype: string 

33 """ 

34 return self._content 

35 

36 @content.setter 

37 def content(self, value): 

38 """The actual AMP HTML content. 

39 

40 :param value: The actual AMP HTML content. 

41 :type value: string 

42 """ 

43 self._validator.validate_message_dict(value) 

44 self._content = value 

45 

46 def get(self): 

47 """ 

48 Get a JSON-ready representation of this AmpContent. 

49 

50 :returns: This AmpContent, 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 

56 

57 if self.content is not None: 

58 content["value"] = self.content 

59 return content