apicrud.messaging.format

format.py

created 15-aug-2020 by docker@instantlinux.net

Classes

MessageFormat([db_session, account_id, ...])

MIME and SMS formatting

class apicrud.messaging.format.MessageFormat(db_session=None, account_id=None, smtp=None, settings=None)

MIME and SMS formatting

email(template, frm, sender_email, to, attachments=[], **kwargs)

Format an email message with mime attachment, in the user’s profile-determined locale

Parameters:
  • template (str) – jinja2 template name

  • frm (Contact) – contact of sender

  • sender_email (str) – destination address

  • to (Contact) – contact of recipient

  • attachments (list) – additional MIMEBase / MimeText objects

  • **kwargs – other key=value pairs for jinja2 substitution

Returns:

mime object (use .as_string() to convert to message)

Return type:

obj

sms(template, frm, to, **kwargs)

Format an SMS message

Parameters:
  • template (str) – jinja2 template name

  • frm (Contact) – contact of sender

  • to (Contact) – contact of recipient

  • **kwargs – other key=value pairs for jinja2 substitution

Returns:

Formatted string content

Return type:

str