Low-level API Unisender

Usage:

from django_tasker_unisender.unisender import Unisender

unisender = Unisender(api_key="<< api key >>")
lists = unisender.get_lists()
print(lists)
class django_tasker_unisender.unisender.Unisender(api_key: str = None)

Base class to work with low-level API Unisender

create_field(name: str, field_type: str, public_name: str = None) → int

It is a method to create a new user field, the value of which can be set for each recipient, and then it can be substituted in the letter.

Parameters:
  • name – Variable to be substituted. It must be unique and case sensitive. Also, it is not recommended to create a field with the same name as the standard field names (tags, email, phone, email_status, phone_status, etc.) as the importContacts. Admissible characters: Latin letters, numbers, «_» and «-». The first character must be a letter. No spaces are allowed.
  • field_type – Field type Possible options: (string — string, text — one or more strings, number — integer or number with decimal point date — date (the DD.MM.YYYY, DD-MM-YYYY, YYYY.MM.DD, YYYY-MM-DD format is supported) bool — 1/0, yes/no )
  • public_name – Field name. If it is not used, an automatical generation by the «name» field will take place.
Returns:

Identifier field_id

create_list(title: str) → int

Checks the validity of a mobile phone number.

Parameters:title – List name. It must be unique in your account.
Returns:Identifier campaign list
delete_field(field_id: int) → None

It is a method to delete a user field.

Parameters:field_id – Identifier field_id
delete_list(list_id: int) → None

It is a method to delete a list.

Parameters:list_id – Identifier campaign list
exclude(contact_type: str, contact: str, list_ids: list = None) → None

The method excludes the contact’s email or phone number from one or several lists.

Parameters:
  • contact_type – The type of the contact to be excluded is either ’email’ or ‘phone’
  • contact – Email or phone being excluded
  • list_ids – List codes separated by comma from which contacts are being excluded. If it is not specified, contacts will be excluded from all lists.
get_email(email: str) → dict

The method get the contact’s email.

Parameters:email – Email address
Returns:dictionary data
get_fields() → list

Array, each array element is an object with the id, name, type, is_visible and view_pos fields.

get_lists() → list

It is a method to get the list of all available campaign lists.

Returns:Array, each array element is an object dict with the following id and title fields.
subscribe(list_ids: list, fields: dict, double_optin: int = 3, overwrite: int = 0) → int

This method adds contacts (email address and/or mobile phone numbers) of the contact to one or several lists, and also allows you to add/change values of additional fields and tags.

Parameters:
  • list_ids – List codes separated by comma in which a contact is to be added.
  • fields – Dictionaries of additional fields.
  • double_optin – It obtains the value of 0, 3, or 4. (3 by default) (see https://www.unisender.com/en/support/api/partners/subscribe/)
  • overwrite – Field and tag rewriting mode, the number from 0 to 2 (0 by default). It sets what needs to be done in case of existence of a contact (the contact is identified by the email address and/or phone number).
Returns:

Identifier person

update_field(field_id: int, name: str, public_name: str = None) → None

It is a method to change user field parameters.

Parameters:
  • field_id – Identifier field_id
  • name – Field name. It must be unique and case insensitive. Also, it is not recommended to create a field with the same name as the standard field names (tags, email, phone, email_status, phone_status, etc.) as the importContacts method will work incorrectly.
  • public_name – Field name. Name of the «variable for substitution». field in the personal account. If it is not used, an automatically generation by the «name» field will take place. Admissible characters: Latin letters, numbers, «_» and «-». The first character must be a letter. No spaces are allowed.
update_list(list_id: int, title: str) → None

It is a method to change campaign list properties.

Parameters:
  • list_id – Identifier campaign list.
  • title – List name. It must be unique in your account.