+49 69 83008980 service@xqueue.com
Benötigen Sie Hilfe?

Im Maileon Help-Center finden Sie umfassende Dokumentationen zu unserem System.

Beliebte Suchanfragen: Importe | Rest-API | Integrationen | SMS

Contactfilters

Sie sind hier:
This page describes the data fields of a contactfilter and how to de-/serialize a contact as XML.

Contact Filter

This section describes the attributes of a contact. The entry “Passed as XML” describes whether this attribute is submitted to the API as XML (if “yes”) or as parameter of the REST call (if “no”).

Attribute / Type Default Passed as XML Description
id / long No The ID of a contactfilter
name String Yes The (display) name of a contactfilter
author String Yes The email adress of the author of a ontactfilter
state String Yes The state of the contact filter, can be one of: ‘outofdate’,’updating’,’uptodate
created String Yes At the date when the contactfilter was created in standard SQL format:/ yyyy-MM-dd HH:mm:ss
updated String Yes The last date when the contactfilter was updated in standard SQL format:/ yyyy-MM-dd HH:mm:ss
count_contacts int Yes The number of contacts that match the filter
count_rules int Yes The number of rules in the filter

XML Representation

This is an example of an XML representation of a contactfilter:

<?xml version="1.0" encoding="UTF-8"?>
<contactfilter>
   <id>1</id>
   <name>MySampleFilter</name>
   <author>xq-freiburg@xqueue.com</author>
   <state>uptodate</state>
   <created>2013-02-15 10:48:38</created>
   <count_contacts>12</count_contacts>
   <count_rules>1</count_rules>
</contactfilter>

Sample Java-Deserializer

This code example shows a deserializer for contactfilters (written in Java):

public static final String XML_ID = "id";
public static final String XML_NAME = "name";
public static final String XML_AUTHOR = "author";
public static final String XML_STATE = "state";
public static final String XML_CREATED = "created";
public static final String XML_COUNT_CONTACTS = "count_contacts";
public static final String XML_COUNT_RULES = "count_rules";
public static final String XML_CONTACT_FILTER = "contactfilter";
public static final String XML_CONTACT_FILTERS = "contactfilters";

public static ContactFilter deserializeSingleElement(Element filter) throws Exception {
 
 if (XML_CONTACT_FILTER.equals(filter.getName())) {
 	ContactFilter cf = new ContactFilter();
 	
 	// ID
 	Element id = filter.element(XML_ID);
 	if (id != null) {
 		try {
 			cf.setId(Long.parseLong(id.getText()));
        } catch (Exception e) {
            throw new NumberFormatException("Not a valid ID: " + id.getText());
        }
 	}
 	
 	// Name
 	Element name = filter.element(XML_NAME);
 	if (name != null) {
 		cf.setName(name.getText());
 	}
 	
 	// Author
 	Element author = filter.element(XML_AUTHOR);
 	if (author != null) {
 		cf.setAuthor(author.getText());
 	}
 	
 	// State
 	Element state = filter.element(XML_STATE);
 	if (state != null) {
 		cf.setStatus(state.getText());
 	}
 	
 	// Created
 	Element created = filter.element(XML_CREATED);
 	if (created != null) {
 		try {
 			cf.setCreated(created.getText());
        } catch (Exception e) {
            throw new NumberFormatException("Not a valid date: " + created);
        }
 	}
 	
 	// Count Contacts
 	Element count_contacts = filter.element(XML_COUNT_CONTACTS);
 	if (count_contacts != null) {
 		try {
 			cf.setCountContacts(Integer.parseInt(count_contacts.getText()));
        } catch (Exception e) {
            throw new NumberFormatException("Not a int number for counted contacts: " + count_contacts.getText());
        }
 	}
 	
 	// Count Rules
 	Element count_rules = filter.element(XML_COUNT_RULES);
 	if (count_rules != null) {
 		try {
 			cf.setCountRules(Integer.parseInt(count_rules.getText()));
        } catch (Exception e) {
            throw new NumberFormatException("Not a int number for counted rules: " + count_rules.getText());
        }
 	}
 	
 	return cf;
 	
 } else throw new Exception(String.format("Root element of a single contact filter must be named '%s' but is named: '%s'", XML_CONTACT_FILTERS, XML_CONTACT_FILTER, filter.getName()));	 
}

De-/Serializing Several Contacts

Some methods like/ getContactfilters/ require to pass several contactfilters at the same time. Serializing several contactfilters is done using a wrapping <contactfilters></contactfilters> tag.

<contactfilters>
    <contactfilter>
        <id>1</id>
        [...]
    </contactfilter>
    <contactfilter>
        <id>007</id>
        [...]
    </contactfilter>
</contactfilters>
Inhaltsverzeichnis