extranet/library/Giant/WSgiant.php
2013-09-18 12:49:04 +00:00

336 lines
9.9 KiB
PHP

<?php
ini_set('max_execution_time', 300);
require_once ('Functions.lib.php');
define("DATA_SET_VERSION", '1.0');
class WSgiant extends Zend_Soap_Client
{
protected $wsService = array();
protected $header;
protected $TestIndication;
function __construct($parametres,$TestIndication)
{
$this->wsService = new Zend_Config_Ini( realpath(dirname(__FILE__)).'/giant.ini' );
$this->TestIndication = $TestIndication;
if($parametres InstanceOF stdClass)
self::init($parametres);
}
/**
* init
* @param unknown_type $parametres
*/
private function init($parametres)
{
$password='password'.$this->TestIndication;
$utilisateur = new Scores_Utilisateur();
$options = array(
'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS,
'soapVersion' => SOAP_1_1,
'login' => $this->wsService->options->login,
'password' => $this->wsService->options->$password,
'compression' => SOAP_COMPRESSION_ACCEPT
);
$this->setOptions($options);
$giantHeader = new stdClass();
$giantHeader->ConsumerId = $this->wsService->header->ConsumerId;
$giantHeader->CustomerId = $utilisateur->getLogin();
$giantHeader->Provider = new stdClass();
$giantHeader->Provider->CountryCode = $parametres->CountryCode;
$giantHeader->Provider->ProviderId = $parametres->ProviderId;
$giantHeader->TimeStamp = time();
$giantHeader->TestIndication = $parametres->TestIndication;
$this->header = new SoapHeader(
$this->wsService->header->url,
$this->wsService->header->serviceName, $giantHeader
);
parent::addSoapInputHeader($this->header, true);
}
/**
* getAllMethodesFromWsdl
* @param unknown_type $service
*/
public function getAllMethodesFromWsdl($service)
{
$wsdl = 'wsdl'.$this->TestIndication;
$this->setWsdl($this->wsService->$service->$wsdl);
return ($this);
}
}
Class Search extends GiantFunction
{
private $soapG;
protected $label;
protected $labelResults;
protected $query;
protected $methodes = array(
'search',
'advancedSearch'
);
private $headerSearch;
public function __construct($soap)
{
$this->soapG = $soap;
$this->label = new Zend_Config_Ini('Giant/Traductions/label.ini', 'search');
$this->labelResults = new Zend_Config_Ini('Giant/Traductions/results.ini', 'search');
$this->headerSearch = new stdClass();
$this->headerSearch->IncludePhoneticMatches = FALSE;
$this->headerSearch->IncludeSuggestions = FALSE;
$this->soapG->getAllMethodesFromWsdl('search');
}
protected function search($paramatres, $page)
{
$this->query = $paramatres->Query;
$search = array_merge((array)$paramatres, (array)$this->headerSearch);
try {
$result = $this->soapG->search($search);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
public function advancedSearch($parametres, $page)
{
$advanced = array_merge((array)$parametres, (array)$this->headerSearch);
$this->query = $advanced['Query'];
try {
$result = $this->soapG->advancedSearch($advanced);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return($result);
}
protected function Tier2Search($Query, $StartRow, $NumRows)
{
$parametres = new stdClass();
$parametres->Query = $Query;
$parametres->StartRow = $StartRow;
$parametres->NumRows = $NumRows;
try {
$this->soapG->Tier2Search($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
}
public function Tier2SearchMethods()
{
try {
$result = $this->soapG->Tier2SearchMethods();
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
public function __destruct()
{
unset($this->soapG);
}
}
Class CreditData extends GiantFunction
{
private $soapG;
protected $companyId;
protected $methodes = array(
'RetreiveOptions', 'OrderDataSet',
'RetrieveOrderStatus', 'RetrieveDataSet',
'StartInvestigation', 'StartMonitoring',
'UpdateMonitoringOptions', 'StopMonitoring',
'RetrieveMonitoringEventsForOrder', 'RetrieveMonitoringEventsForCustomer',
'RetrieveMonitoringEventsForConsumer', 'Ping'
);
public function __construct($soapG, $companyId)
{
$this->soapG = $soapG;
$this->companyId = $companyId;
$this->soapG->getAllMethodesFromWsdl('credit-data');
}
protected function RetreiveOptions()
{
$parametres = new stdClass();
$parametres->CompanyId = $this->companyId;
try {
$result = $this->soapG->RetrieveOptions($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function OrderDataSet($DataSetType, $LanguageCode, $Version = null)
{
$parametres = new stdClass();
$parametres->CompanyId = $this->companyId;
$parametres->DataSetType = $DataSetType;
$parametres->DataSetVersion = DATA_SET_VERSION;
$parametres->LanguageCode = $LanguageCode;
try {
$result = $this->soapG->OrderDataSet($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function RetrieveOrderStatus($InternalOrderId)
{
$parametres = new stdClass();
$parametres->InternalOrderId = $InternalOrderId;
try {
$result = $this->soapG->RetrieveOrderStatus($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function RetrieveDataSet($InternalOrderId)
{
$parametres = new stdClass();
$parametres->InternalOrderId = $InternalOrderId;
try {
$result = $this->soapG->RetrieveDataSet($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function StartInvestigation($DataSetType, $ServiceLevelName, $Version = null, $LanguageCode = null)
{
$parametres = new stdClass();
$parametres->DataSetType = $DataSetType;
$parametres->ServiceLevelName = $ServiceLevelName;
$parametres->Version = $Version;
$parametres->LanguageCode = $LanguageCode;
try {
$result = $this->soapG->StartInvestigation($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function StartMonitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode)
{
$parametres = new stdClass();
$parametres->CompanyId = $CompanyId;
$parametres->CategoryName = $CategorieName;
$parametres->EventType = $EventType;
if (!empty($PreferredStartDate)) {
$parametres->PreferredStartDate = $PreferredStartDate;
}
if (!empty($PreferredEndDate)) {
$parametres->PreferredEndDate = $PreferredEndDate;
}
$parametres->MonitoringVersion = $Version;
$parametres->LanguageCode = $LanguageCode;
try {
$result = $this->soapG->StartMonitoring($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function UpdateMonitoringOptions($CompanyId, $InternalOrderId, $CategorieName, $EventType, $PreferredStartDate, $Version, $LanguageCode)
{
$parametres = new stdClass();
$parametres->InternalOrderId = (float)$InternalOrderId;
if (!empty($CategorieName)) {$parametres->NewCategoryName = $CategorieName;}
if (!empty($EventType)) {$parametres->NewEventType = $EventType;}
if (!empty($PreferredStartDate)) {$parametres->PreferredStartDate = $PreferredStartDate;}
if (!empty($Version)) {$parametres->NewMonitoringVersion = $Version;}
if (!empty($LanguageCode)) {$parametres->NewLanguageCode = $LanguageCode;}
try {
$result = $this->soapG->UpdateMonitoringOptions($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function StopMonitoring($CompanyId, $PreferredEndDate, $InternalOrderId)
{
$parametres = new stdClass();
$parametres->CompanyId = $CompanyId;
$parametres->PreferredEndDate = $PreferredEndDate;
$parametres->InternalOrderId = (float)$InternalOrderId;
try {
$result = $this->soapG->StopMonitoring($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function RetrieveMonitoringEventsForOrder($CompanyId, $StartFrom,$InternalOrderId)
{
$parametres = new stdClass();
$parametres->InternalOrderId = (float)$InternalOrderId;
if (!empty($StartFrom)) {$parametres->StartFrom = $StartFrom;}
try {
$result = $this->soapG->RetrieveMonitoringEventsForOrder($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function RetrieveMonitoringEventsForCustomer($CompanyId, $StartFrom)
{
$parametres = new stdClass();
if (!empty($StartFrom)) {$parametres->StartFrom = $StartFrom;}
try {
$result = $this->soapG->RetrieveMonitoringEventsForCustomer($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function RetrieveMonitoringEventsForConsumer($CompanyId, $StartFrom)
{
$parametres = new stdClass();
if (!empty($StartFrom)) {$parametres->StartFrom = $StartFrom;}
try {
$result = $this->soapG->RetrieveMonitoringEventsForConsumer($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
protected function Ping($Type)
{
$parametres = new stdClass();
$parametres->Type = $Type;
try {
$result = $this->soapG->Ping($parametres);
} catch (SoapFault $soapFault) {
echo 'Erreur Soap : '.$soapFault->getMessage();
}
return ($result);
}
public function __destruct()
{
unset($this->soapG);
}
}