* needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <*****@*****.**>
 * @copyright 2007-2015 PrestaShop SA
 * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
*/
include_once realpath(dirname(__FILE__) . '/../../') . '/config/config.inc.php';
include_once _PS_MODULE_DIR_ . 'mailjet/classes/MailJetLog.php';
include_once _PS_MODULE_DIR_ . 'mailjet/classes/MailJetTranslate.php';
include_once _PS_MODULE_DIR_ . 'mailjet/classes/MailJetEvents.php';
include_once _PS_MODULE_DIR_ . 'mailjet/classes/hooks/Events.php';
include_once _PS_ROOT_DIR_ . '/init.php';
require_once _PS_MODULE_DIR_ . 'mailjet/mailjet.php';
$mj = new Mailjet();
if ($mj->getEventsHash() !== Tools::getValue('h')) {
    header('HTTP/1.1 401 Unauthorized');
    return;
}
# Catch Event
$post = trim(Tools::file_get_contents('php://input'));
# No Event sent
if (empty($post)) {
    header('HTTP/1.1 421 No event');
    /* => do action */
    return;
}
# Decode Trigger Informations
$t = Tools::jsonDecode($post, true);
# No Informations sent with the Event
if (!is_array($t) || !isset($t['event'])) {