src/XQueue/Maileon/API/Contacts/ContactsService.php
function createContact($contact, $syncMode, $src = "",
                           $subscriptionPage = "", $doi = FALSE, $doiPlus = FALSE, $doiMailingKey = "")
    {
        $queryParameters = array(
            'sync_mode' => $syncMode->getCode(),
            'src' => $src,
            'subscription_page' => $subscriptionPage,
            'doi' => ($doi == TRUE) ? "true" : "false",
            'doiplus' => ($doiPlus == TRUE) ? "true" : "false"
        );


        // As empty does not work with return values (sometimes?), first trim the variable, then check it
        $doiMailingKey = trim($doiMailingKey);
        if (!empty($doiMailingKey)) {
            $queryParameters['doimailing'] = $doiMailingKey;
        }

        if (isset($contact->permission)) {
            $queryParameters['permission'] = $contact->permission->getCode();
        }

        // The API allows only some of the fields to be submitted
        $contactToSend = new Contact(null, $contact->email, null, $contact->external_id, null, $contact->standard_fields, $contact->custom_fields);

        return $this->post("contacts/" . $contactToSend->email, $contactToSend->toXMLString(), $queryParameters);
    }
function createContact($contact, $syncMode, $src = "",
                           $subscriptionPage = "", $doi = FALSE, $doiPlus = FALSE, $doiMailingKey = "")
    {
        $queryParameters = array(
            'sync_mode' => $syncMode->getCode(),
            'src' => $src,
            'subscription_page' => $subscriptionPage,
            'doi' => ($doi == TRUE) ? "true" : "false",
            'doiplus' => ($doiPlus == TRUE) ? "true" : "false"
        );


        // As empty does not work with return values (sometimes?), first trim the variable, then check it
        $doiMailingKey = trim($doiMailingKey);
        if (!empty($doiMailingKey)) {
            $queryParameters['doimailing'] = $doiMailingKey;
        }

        if (isset($contact->permission)) {
            $queryParameters['permission'] = $contact->permission->getCode();
        }

        // The API allows only some of the fields to be submitted
        $contactToSend = new Contact(null, $contact->email, null, $contact->external_id, null, $contact->standard_fields, $contact->custom_fields);

        return $this->post("contacts/" . $contactToSend->email, $contactToSend->toXMLString(), $queryParameters);
    }
Creates or updates a contact and optionally triggers a double opt-in (doi) process.
Note that none of the attributes is required.

@param com_maileon_api_contacts_Contact $contact
the contact to create or update; if no permission is set, the Maileon default permission "NONE" will be used
@param com_maileon_api_contacts_SynchronizationMode $syncMode
the synchronization mode to employ
@param string $src
A string intended to describe the source of the contact.
If provided, the string will be stored with the doi process.
@param string $subscriptionPage
In case where this method was called by a subscription page,
this string offers the possibility to keep track of it for use in reports.
@param bool $doi
Tells whether a double opt-in process should be started for the created contact.
Note that the status code returned for this request does not mean that the doi
process succeeded.
@param bool $doiPlus
This parameter is ignored if doi is not provided or false. In case the doi
process succeeds, Maileon will be allowed to track opens and clicks of the contact.
@param string $doiMailingKey
This parameter is ignored if doi is not provided or false. References the
doi mailing to be used. If not provided, the default doi mailing will be used.
@return \em com_maileon_api_MaileonAPIResult
the result object of the API call
@throws com_maileon_api_MaileonAPIException
if there was a connection problem or a server error occurred