<?php
/*------------------------------------------------------------------------------
   
   * * * ----------------------------------------------------------------- * * *
   * * * DIESES SCRIPT IST PRIVAT UND DARF NICHT OHNE DIE AUSDRUECKLICHE   * * *
   * * * GENEHMIGUNG DES AUTORS, WEDER FUER PRIVATE NOCH FUER KOMMERZIELLE * * *
   * * * ZWECKE, VERWENDET WERDEN.                                         * * *
   * * * ----------------------------------------------------------------- * * *
   
                                              Author M. ASPELEITER <dazze@gmx.de
                                             Copyright (c) 2004 mario aspeleiter
					     
   ---------------------------------------------------------------------------*/

ini_set('memory_limit','1200M');
error_reporting(E_ALL);

define("EBAYAPI",true);

require('includes/application_top.php');
require('admin/includes/config.ebayapi.inc.php');
require_once(DIR_FS_DOCUMENT_ROOT.'admin/includes/classes/class.ebay.php');

require_once ABS_PATH_TO_PHPAPI.'ebat/EbatNs_ServiceProxy.php';
require_once ABS_PATH_TO_PHPAPI.'ebat/EbatNs_Logger.php';
require_once ABS_PATH_TO_PHPAPI.'ebat/SetNotificationPreferencesRequestType.php';
require_once ABS_PATH_TO_PHPAPI.'ebat/GetNotificationPreferencesRequestType.php';
require_once ABS_PATH_TO_PHPAPI.'ebat/GetNotificationsUsageRequestType.php';

$EBAYAPI = new ebayAPI;
set_time_limit(0);

$session = new EbatNs_Session(ABS_PATH_TO_PHPAPI.'config/ebay.config.php');
$session->setRequestToken( $EBAYAPI->getToken() );
$session->setSiteID(77);
$session->setErrorLanguage('DE');

$cs = new EbatNs_ServiceProxy($session);
//$cs->attachLogger(new EbatNs_Logger(false),'stdout');
/*
$req = new SetNotificationPreferencesRequestType();
$user = new NotificationEnableArrayType();
	$app = new NotificationEnableType();
	$app->setEventEnable('Enable');
	$app->setEventType('EndOfAuction');
$user->NotificationEnable[] = $app;
	$app = new NotificationEnableType();
	$app->setEventEnable('Enable');
	$app->setEventType('FixedPriceTransaction');
$user->NotificationEnable[] = $app;
	$app = new NotificationEnableType();
	$app->setEventEnable('Enable');
	$app->setEventType('BestOffer');
$user->NotificationEnable[] = $app;


$req->setUserDeliveryPreferenceArray($user);

$ad = new ApplicationDeliveryPreferencesType();
$ad->setApplicationURL('mailto://mario.aspeleiter@agri-consulting.de');
$ad->setApplicationEnable('Enable');
$ad->setAlertEmail('mailto://mario.aspeleiter@agri-consulting.de');
$req->setApplicationDeliveryPreferences($ad);

$res = $cs->SetNotificationPreferences($req);
*/

//simulate calls
$req = new GetNotificationsUsageRequestType();
$req->setStartTime('2007-02-04');
$req->setEndTime('2007-02-05');
$res = $cs->GetNotificationsUsage($req);
$stat = $res->getNotificationStatistics();
?>
<table border="1">
<tr bgcolor="#cacaca"><td><b>Konfiguration</b></td></tr>
<tr bgcolor="#DDDDDD">
	<td><b>Statistics</b><br>
	<table border="0">
	<tr>
		<td>Delivered: <?php echo $stat->getDeliveredCount(); ?></td>
		<td>&nbsp;</td>
		<td>QueuedNewCount: <?php echo $stat->getQueuedNewCount(); ?></td>
		<td>&nbsp;</td>
		<td>QueuedPendingCount: <?php echo $stat->getQueuedPendingCount(); ?></td>
		<td>&nbsp;</td>
		<td>ExpiredCount: <?php echo $stat->getExpiredCount(); ?></td>
		<td>&nbsp;</td>
		<td>ErrorCount: <?php echo $stat->getErrorCount(); ?></td>
	</tr>
	</table>
	</td>
</tr>
<tr><td>
	<br><b>Application-Data:</b>
	<pre><?php 
// SEE THE RESULT
$req = new GetNotificationPreferencesRequestType();

$req->setPreferenceLevel('Application');
$res = $cs->GetNotificationPreferences($req);
print_r($res->getApplicationDeliveryPreferences()); 
?></pre>
	<br><b>User-Preferences:</b>
	<pre><?php 
$req->setPreferenceLevel('User');
$res = $cs->GetNotificationPreferences($req);
print_r($res->getUserDeliveryPreferenceArray()); 
?></pre>
	<br><b>User-Data:</b>
	<pre><?php 
$req->setPreferenceLevel('UserData');
$res = $cs->GetNotificationPreferences($req);
print_r($res->getUserData()); 
?></pre>
	<br><b>Event Property:</b>
	<pre><?php print_r($res->getEventProperty($index = null)); ?></pre>
</td></tr>
</table>
