Import and create an instance of the API wrapper which is built around xmlrpclib. Note that authentication errors will not surface until calls are made.
>>> from pymessagefocus import *
>>> MessageFocusClient
<class 'pymessagefocus.pymessagefocus.MessageFocusClient'>
>>> messagefocus = MessageFocusClient('organisation', 'username', 'password')
>>> messagefocus
<pymessagefocus.pymessagefocus.MessageFocusClient object at 0x7f13cbfc2050>
==========
Add contact to list
Add contact with core and data table properties and associate it with a list. Data table fields are identified by putting the data table id in front of the field name.
core_table_id = 1
list_id = 2
email_address = 'person@example.com'
contact_data = {'email': email_address,
'title': 'Mr',
'4.field': 'value'}
messagefocus.add_contact_to_list(core_table_id,
list_id,
contact_data)
==========
Get contact
Using either email address or contact id. Note that this does not include the data table fields.
core_table_id = 1
email_address = 'person@example.com'
messagefocus.get_core_data_for_email_address(core_table_id,
email_address)
contact_id = 1
messagefocus.get_core_data_for_contact_id(contact_id)
==========
Send transactional message
The person being sent to must exist in the core table identified by core_table_id and may be identified either by their email address or their contact id. Optionally provide a dictionary of transaction data as a dictionary keyword argument.
core_table_id = 1
campaign_id = 1
email_address = 'person@example.com'
messagefocus.transactional(core_table_id,
campaign_id,
email_address=email_address)
core_table_id = 1
campaign_id = 1
contact_id = 1
messagefocus.transactional(core_table_id,
campaign_id,
contact_id=contact_id)
==========
Get lists and tables
messagefocus.get_lists()
messagefocus.get_data_tables()
messagefocus.get_core_tables()