Components

Once you instantiate an object of type List, Group, Recipient, etc.. you can use the following methods provided by the relative class. All components have some common behaviors:

id:property to get/set id of component
save:method to save component changes on MailUp (see below for detail)
client:MailUpClient instance used to call MailUp API
logger:logger
data_dict:internal dictionary related to received json
mailup_pattern_fields:
 dictionary where the keys are which fields of json must be configured as component attributes and values the names that you want give to them
required_fields:
 list of required items in data_dict
get_list method:
 method that return List in which is located the component, if component is a List return himself

List

save

save()

Save the List on MailUp platform. If the object as no id then a new object is created on MailUp.

Returns:

List Instance

Return type:

List or Group or Recipient or Message or Tag based on caller instance.

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

get_groups

get_groups()

Retrieve all groups in list

Returns:

list of Group instance

Return type:

list

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

get_recipients

get_recipients(status=None)

Retrieve all recipients in list. If status is None all recipients are returned regardless of the status

Parameters:

status (str) – status is a string in ‘subscribed’ ‘unsubscribed’ or ‘pending’, None for consider all

Returns:

list of Recipient instance

Return type:

list

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

get_subscribers

get_subscribers()

Retrieve all recipients in subscribed status in list

Returns:

list of Recipient instance

Return type:

list

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

get_unsubscribers

get_unsubscribers()

Retrieve all recipients in unsubscribed status in list

Returns:

list of Recipient instance

Return type:

list

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

get_pending

get_pending()

Retrieve all recipients in pending status in List

Returns:

list of Recipient instance

Return type:

list

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

subscribe_recipients_list

subscribe_recipients_list(recipients, confirm_email=False, wait_import=False)

Subscribe all recipient in recipients in List

Parameters:
  • recipients (list) – list of Recipient instance
  • confirm_email (bool) – refer to MailUp documentation
  • wait_import (bool) – method ends only when import is complete
Returns:

import_id

Return type:

int

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

subscribe_recipients_list_forced

subscribe_recipients_list_forced(recipients, confirm_email=False, wait_import=False)

Subscribe all recipient in recipients in list, are subscribe both pending the unsubscribed

Parameters:
  • recipients (list) – list of Recipient instance
  • confirm_email (bool) –

    refer to MailUp documentation

  • wait_import (bool) – method ends only when import is complete
Returns:

import_id

Return type:

int

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

unsubscribe_recipients_list

unsubscribe_recipients_list(recipients, wait_import=False)

Unsubscribe all recipient in recipients from List

Parameters:
  • recipients (list) – list of Recipient instance
  • wait_import (bool) – method ends only when import is complete
Returns:

import_id

Return type:

int

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

send_confirmation_email

send_confirmation_email(import_id, send_date=None)

A confirmation email is sent at all recipient subscribed in import_id import.

Parameters:
  • import_id (int) – id of import (see unsubscribe_recipients_list)
  • send_date (datetime) – datetime to send message, None to send instantly.
Returns:

sending info and statistic

Return type:

dict

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

get_import_status

get_import_status(import_id)

Retrieve status of import import_id. If import_id is not valid None is returned from MailUp and then from this methods.

Parameters:

import_id (int) – id of import to retrieve status

Returns:

import statistics

Return type:

dict

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

Group

save

save()

Save the Group on MailUp platform. If the object as no id then a new object is created on MailUp.

Returns:

Group Instance

Return type:

List or Group or Recipient or Message or Tag based on caller instance.

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

delete

delete()

Delete instantly the group on MailUp

Returns:

None

Return type:

None

Raises:
  • GroupNotFoundException – group (searched by id) not found
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

get_subscribers

get_subscribers()

Retrieve all recipients in subscribed status in group

Returns:

list of Recipient instance

Return type:

list

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

insert_recipient

insert_recipient(recipient_id)

Insert recipient with id = recipient_id in group

Parameters:

recipient_id (int) – id of recipient to insert

Returns:

None

Return type:

None

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

extract_recipient

extract_recipient(recipient_id)

Extract recipient with id = recipient_id from group

Parameters:

recipient_id (int) – id of recipient to extract

Returns:

None

Return type:

None

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

subscribe_recipients_list

subscribe_recipients_list(recipients, confirm_email=False, wait_import=False)

Subscribe all recipient in recipients in group

Parameters:
  • recipients (list) – list of Recipient instance
  • confirm_email (bool) –

    refer to MailUp documentation

  • wait_import (bool) – method ends only when import is complete
Returns:

import_id

Return type:

int

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

subscribe_recipients_list_forced

subscribe_recipients_list_forced(recipients, confirm_email=False, wait_import=False)

Subscribe all recipient in recipients in group, are subscribe both pending the unsubscribed

Parameters:
  • recipients (list) – list of Recipient instance
  • confirm_email (bool) –

    refer to MailUp documentation

  • wait_import (bool) – method ends only when import is complete
Returns:

import_id

Return type:

int

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

unsubscribe_recipients_list

unsubscribe_recipients_list(recipients, wait_import=False)

Unsubscribe all recipient in recipients from group

Parameters:
  • recipients (list) – list of Recipient instance
  • wait_import (bool) – method ends only when import is complete
Returns:

import_id

Return type:

int

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

send_confirmation_email

send_confirmation_email(import_id, send_date=None)

A confirmation email is sent at all recipient subscribed in import_id import.

Parameters:
  • import_id (int) – id of import (see unsubscribe_recipients_list)
  • send_date (datetime) – datetime to send message, None to send instantly.
Returns:

sending info and statistic

Return type:

dict

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

send_message

send_message(message_id)

Message message_id is sent to group

Parameters:

message_id (int) – id of message to send

Returns:

sending info and statistic

Return type:

dict

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

Recipient

save

save()

Save the Recipient on MailUp platform. If the object as no id then a new object is created on MailUp.

Returns:

Recipient Instance

Return type:

List or Group or Recipient or Message or Tag based on caller instance.

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

add_to_list

add_to_list(list_id, confirm_email=False)

Add a recipient in list

Parameters:
  • list_id (int) – id of the list in which to insert the recipient
  • confirm_email (bool) –

    refer to MailUp documentation

Returns:

Recipient instance

Return type:

Recipient

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

subscribe_to_list

subscribe_to_list(list_id)

Subscribe a recipient in list

Parameters:

list_id (int) – id of the list in which to subscribe the recipient

Returns:

Recipient instance

Return type:

Recipient

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

unsubscribe_to_list

unsubscribe_to_list(list_id)

Unsubscribe a recipient in list

Parameters:

list_id (int) – id of the list in which to unsubscribe the recipient

Returns:

Recipient instance

Return type:

Recipient

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

add_to_group

add_to_group(group_id, confirm_email=False)

Add a recipient in a group

Parameters:
  • group_id (int) – id of the group in which to unsubscribe the recipient
  • confirm_email (bool) –

    refer to MailUp documentation

Returns:

Recipient instance

Return type:

Recipient

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

set_field

set_field(field_name, field_value)

Set a recipient field, save() method is necessary to align MailUp platform

Parameters:
  • field_name (str) – name of field to set
  • field_value (str) – value to be assigned to the field
Returns:

None

Return type:

None

get_field

get_field(field_name)

Get the value of field_name

Parameters:field_name (str) – name of field to get
Returns:value of field
Return type:str

set_fields

set_fields(field_dict)

Set a recipient fields through a dictionary where the keys are fields name and the values are the fields values, save() method is necessary to align MailUp platform.

Parameters:field_dict (dict) – dict of fields
Returns:None
Return type:None

get_fields

get_fields()

Get a dictionary of fields where the keys are fields name and the values are the fields values

Returns:dictionary of fields
Return type:dict

Message

save

save()

Save the Message on MailUp platform. If the object as no id then a new object is created on MailUp.

Returns:

Message Instance

Return type:

List or Group or Recipient or Message or Tag based on caller instance.

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

send_to_list

send_to_list(list_id)

Send message to list

Parameters:

list_id (int) – id of the list to which to send the message

Returns:

sending info and statistic

Return type:

dict

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

send_to_group

send_to_group(group_id)

Send message to group

Parameters:

group_id (int) – id of the group to which to send the message

Returns:

sending info and statistic

Return type:

dict

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

send_to_recipient

send_to_recipient(recipient_id)

Send message to recipient

Parameters:

group_id (int) – id of the recipient to which to send the message

Returns:

sending info and statistic

Return type:

dict

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

set_field

set_field(field_name, field_value)

Set a recipient field, save() method is necessary to align MailUp platform

Parameters:
  • field_name (str) – name of field to set
  • field_value (str) – value to be assigned to the field
Returns:

None

Return type:

None

get_field

get_field(field_name)

Get the value of field_name

Parameters:field_name (str) – name of field to get
Returns:value of field
Return type:str

Tag

save

save()

Save the Tag on MailUp platform. If the object as no id then a new object is created on MailUp.

Returns:

Tag Instance

Return type:

List or Group or Recipient or Message or Tag based on caller instance.

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API

Attachment

save

save()

Save the Attachment on MailUp platform. If the object as no id then a new object is created on MailUp.

Returns:

Attachment Instance

Return type:

List or Group or Recipient or Message or Tag based on caller instance.

Raises:
  • ClientNotEnabledException – provider as not a client configured
  • MailUpCallError – Error calling the API