maillift-python

Wrapper around MailLift API


Keywords
api, maillift, letters, devtools, Development
License
GPL-3.0
Install
pip install maillift-python==1.0.2

Documentation

Maillift-Python

A thin wrapper around https://www.maillift.com API. For direct information about this API capabilities, access https://api.maillift.com/

Setup

Install using pip:

pip install maillift-python

Version

1.0.2

Documentation

The wrapper provides access to the API through the use of a few functions:

To get started, import it and instantiate an object:

from maillift import MailLift

# Pass your username and API Key when instantiating
mail_lift  = MailLift(username, api_key)

MailLift.check_price(text)

    """
    :param text: Content of letter
    :return: Float: Total that will be charged (Rounded up)
    """

    mail_lift.check_price(string_with_content)

MailLift.create_letter(recipient, message, **options)

    """
    :param recipient: [REQUIRED] Name + Address combination
    :param message: [REQUIRED] Content to be written to letter
    :param options:
        'sender' : Name + Address combination
        'schedule': Date in the future following YYYY-MM-DD format
        'notes': Send additional information to the writer
    :return: Letter Object or None
    """

    mail_lift.create_letter(recipient, message, sender=sender_info, schedule=delivery_date, notes="Female Handwritting")

MailLift.list_letters(**options)

    """
    :param options:
        'creation_date': Filter by date =YYYY-MM-DD | <=YYYY-MM-DD | >=YYYY-MM-DD | <=YYYY-MM-DD,>=YYYY-MM-DD
        'status': list only letters of the specified status
    :return: list of Letter Objects / Empty List
    """

    mail_lift.list_letters(creation_date="<2016-06-23", status="inMail")

MailLift.get_letter(uuid)

    """
    :param uuid: Universal Unique identifier returned when creating a letter.
    :return: Letter Object or None
    """
    mail_lift.get_letter("7736187-das-8367189da")

MailLift.modify_letter(uuid, message, delivery, **options)

     """
    :param uuid: [REQUIRED] Universal Unique identifier returned when creating a letter.
    :param message: New text for letter
    :param delivery;Date in the future for delivery
    :param options:
        'approval_required': if approval is required (True or False)
    :return: Letter Object or False
     """

    mail_lift.modify_letter("7736187-das-8367189da", message="New text for this letter")

MailLift.cancel_letter(uuid, reason, letter)

    """
    :param uuid: [REQUIRED] Universal Unique identifier returned when creating a letter.
    :param note: Reason to why this note was canceled.
    :param letter: Letter Object. If object is supplied, it will avoid a live call to check its status
    :return: True if able to cancel, False it its past 'In Mail' status.
    """

    mail_lift.cancel_letter("7736187-das-8367189da")

MailLift.letter_history(uuid)

    """
    :param uuid:
    :return: Array with statuses and updates for given letter
    """

    mail_lift.letter_history("7736187-das-8367189da")

Error handling

Errors are raised using MailLiftError, so make sure you catch it properly :)

    try:
        mail_lift.cancel_letter('3128739as8d-das31t62879n')
    except MailLiftError:
        # do something

Contributing

I accept and encourage pull requests. Feature requests are also possible, let's discuss :).

If you find a bug, create an issue please!

To-do

  • Write Tests

License

GPL V3