"""
facilities for wokring with Mandrill `Inbound`_
.. _`Inbound`: https://mandrill.zendesk.com/hc/en-us/articles/360039234693-Inbound-Email-Processing-Overview
"""
import marshmallow
__all__ = (
'MandrillEventSchema',
'MandrillEventMessageSchema',
)
[docs]class MandrillEventSchema(marshmallow.Schema):
"""
top level schema for manndrill `inbound event`_\\s
.. _`inbound event`: https://mandrill.zendesk.com/hc/en-us/articles/360039234693-Inbound-Email-Processing-Overview#inbound-events-format
"""
ts = marshmallow.fields.Integer()
event = marshmallow.fields.String()
msg = marshmallow.fields.Nested('MandrillEventMessageSchema')
[docs]class MandrillEventMessageSchema(marshmallow.Schema):
"""
Details about the message for which the event occurred.
"""
raw_msg = marshmallow.fields.String()
headers = marshmallow.fields.Dict()
text = marshmallow.fields.String()
html = marshmallow.fields.String()
from_email = marshmallow.fields.Email()
from_name = marshmallow.fields.String()
to = marshmallow.fields.List(
marshmallow.fields.List(
marshmallow.fields.String(allow_none=True),
validate=marshmallow.validate.Length(equal=2),
)
)
subject = marshmallow.fields.String()
email = marshmallow.fields.Email()
tags = marshmallow.fields.List(marshmallow.fields.String)
sender = marshmallow.fields.String(allow_none=True)
template = marshmallow.fields.String(allow_none=True)