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

34 statements  

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

1class Substitution(object): 

2 """A string substitution to be applied to the text and HTML contents of 

3 the body of your email, as well as in the Subject and Reply-To parameters. 

4 """ 

5 

6 def __init__(self, key=None, value=None, p=None): 

7 """Create a Substitution with the given key and value. 

8 

9 :param key: Text to be replaced with "value" param 

10 :type key: string, optional 

11 :param value: Value to substitute into email 

12 :type value: string, optional 

13 :param name: p is the Personalization object or Personalization object 

14 index 

15 :type name: Personalization, integer, optional 

16 """ 

17 self._key = None 

18 self._value = None 

19 self._personalization = None 

20 

21 if key is not None: 

22 self.key = key 

23 if value is not None: 

24 self.value = value 

25 if p is not None: 

26 self.personalization = p 

27 

28 @property 

29 def key(self): 

30 """The substitution key. 

31 

32 :rtype key: string 

33 """ 

34 return self._key 

35 

36 @key.setter 

37 def key(self, value): 

38 """The substitution key. 

39 

40 :param key: The substitution key. 

41 :type key: string 

42 """ 

43 self._key = value 

44 

45 @property 

46 def value(self): 

47 """The substitution value. 

48 

49 :rtype value: string 

50 """ 

51 return str(self._value) if isinstance(self._value, int) else self._value 

52 

53 @value.setter 

54 def value(self, value): 

55 """The substitution value. 

56 

57 :param value: The substitution value. 

58 :type value: string 

59 """ 

60 self._value = value 

61 

62 @property 

63 def personalization(self): 

64 """The Personalization object or Personalization object index 

65 

66 :rtype: Personalization, integer 

67 """ 

68 return self._personalization 

69 

70 @personalization.setter 

71 def personalization(self, value): 

72 """The Personalization object or Personalization object index 

73 

74 :param value: The Personalization object or Personalization object 

75 index 

76 :type value: Personalization, integer 

77 """ 

78 self._personalization = value 

79 

80 def get(self): 

81 """ 

82 Get a JSON-ready representation of this Substitution. 

83 

84 :returns: This Substitution, ready for use in a request body. 

85 :rtype: dict 

86 """ 

87 substitution = {} 

88 if self.key is not None and self.value is not None: 

89 substitution[self.key] = self.value 

90 return substitution