File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ def validate_base_message(message: MessageBase):
39
39
if not has_valid_custom_headers (message .custom_headers ):
40
40
return SendResult .MessageValidationInvalidCustomHeaders
41
41
42
+ if message .metadata is not None and len (message .metadata ) > 0 :
43
+ if not has_valid_metadata (message .metadata ):
44
+ return SendResult .MessageValidationInvalidMetadata
45
+
42
46
return SendResult .Success
43
47
44
48
@@ -294,6 +298,23 @@ def has_valid_custom_headers(custom_headers: list):
294
298
return True
295
299
296
300
301
+ def has_valid_metadata (metadata : list ):
302
+ """
303
+ Check if the list of metadata is valid
304
+ :param metadata: list of Metadata to validate
305
+ :type metadata: list
306
+ :return the result
307
+ :rtype bool
308
+ """
309
+ if metadata is None :
310
+ return True
311
+ for item in metadata :
312
+ valid = item .isvalid ()
313
+ if valid is False :
314
+ return False
315
+ return True
316
+
317
+
297
318
def validate_basic_message (message : BasicMessage ):
298
319
"""
299
320
Validate a basic email message before sending to the Injection API.
Original file line number Diff line number Diff line change 1
1
from enum import Enum
2
2
3
3
4
- class SendResult (Enum ):
5
- """
6
- Enumerated result of the client send
4
+ class SendResult (Enum ):
5
+ """
6
+ Enumerated result of the client send
7
7
"""
8
8
9
9
""" An error has occurred that was unforeseen """
@@ -117,6 +117,9 @@ class SendResult(Enum):
117
117
""" SDK Validation Error : Invalid Custom Headers were found in the message """
118
118
MessageValidationInvalidCustomHeaders = 36
119
119
120
+ """ SDK Validation Error : Message contains invalid metadata """
121
+ MessageValidationInvalidMetadata = 37
122
+
120
123
def __str__ (self ):
121
124
"""
122
125
String representation of the SendResult Enum
@@ -167,6 +170,8 @@ def __str__(self):
167
170
35 : "SDK Validation Error : No message body was found in the message" ,
168
171
36 : "SDK Validation Error : "
169
172
"Invalid Custom Headers were found in the message" ,
173
+ 37 : "SDK Validation Error : "
174
+ "Message contains invalid metadata" ,
170
175
}
171
176
return switcher .get (self .value , "An error has occurred that was unforeseen" )
172
177
You can’t perform that action at this time.
0 commit comments