'006', 'BE' => '001', 'ES' => '001', 'GB' => '002', 'NL' => '003' ); protected $DataSetType = array ( 'Full' => 'FU', 'Compact' => 'CO', 'CreditRecommendation' => 'CR', 'Flex' => 'FL', ); public function __construct() { $this->config = new Zend_Config_Ini( realpath(dirname(__FILE__)).'/config.ini' ); } public function setInfos($login, $country) { $this->customerId = $login; $this->CountryCode = $country; $this->ProviderId = $pays[$country]; } public function Search($query = '', $position = 0, $nbRep = 10) { $params = new stdClass(); $params->Query = $query; $params->IncludePhoneticMatches = false; $params->IncludeSuggestions = false; $params->StartRow = $position; $params->NumRows = $nbRep; $client = $this->loadClient('search'); try { return $client->Search($params); } catch (SoapFault $fault) { return $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); } } public function AdvancedSearch($fields, $position = 0, $nbRep = 10) { $params = new stdClass(); $query = new stdClass(); $fieldList = array( 'CompanyId', 'RegisteredName', 'Building', 'Street', 'HouseNumber', 'City', 'PostCode', 'State', 'Country', 'EntireAddress', 'VatNumber', 'CompanyRegisterNumber', 'CompanyWebSite', 'CompanyEmail', 'ParentCompany', 'LegalForm', 'NaceCodes', 'PreviousRegisteredName', 'TelephoneNumbers', 'AddressType' ); foreach ( $fields as $name => $value ) { if ( in_array($name, $fieldList) ) { $query->{$name} = $value; } } $params->Query = $query; $params->IncludeSuggestions = false; $params->StartRow = $position; $params->NumRows = $nbRep; $client = $this->loadClient('search'); try { return $client->Search($params); } catch (SoapFault $fault) { return $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); } } public function RetrieveOptions($CompanyId) { $params = new stdClass(); $params->CompanyId = $CompanyId; $client = $this->loadClient('credit-data'); try { return $client->RetrieveOptions($params); } catch (SoapFault $fault) { return $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); } } public function OrderDataSet($CompanyId, $type, $LanguageCode = 'en') { $params = new stdClass(); $params->CompanyId = $CompanyId; $params->DataSetType = $this->DataSetType[$type]; $params->DataSetVersion = '1.0'; $params->LanguageCode = $LanguageCode; $client = $this->loadClient('credit-data'); try { return $client->OrderDataSet($params); } catch (SoapFault $fault) { return $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); } } public function RetrieveDataSet($InternalOrderId) { $parametres = new stdClass(); $parametres->InternalOrderId = $InternalOrderId; $client = $this->loadClient('credit-data'); try { return $client->RetrieveDataSet($params); } catch (SoapFault $fault) { return $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); } } public function RetrieveOrderStatus($InternalOrderId) { $params = new stdClass(); $params->InternalOrderId = $InternalOrderId; $client = $this->loadClient('credit-data'); try { return $client->RetrieveOrderStatus($params); } catch (SoapFault $fault) { return $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); } } public function Ping($Type) { $params = new stdClass(); $params->Type = $Type; try { return $client->Ping($params); } catch (SoapFault $fault) { return $this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse()); } } /** * loadClient * @param unknown_type $webservice */ protected function loadClient($webservice, $test = false) { if ($test) { $webservice = $this->config['webservices']->test; } else { $webservice = $this->config['webservices']->prod; } $wsdl = $webservice->{$webservice}->wsdl; $options = $webservice->options; $options['features'] = SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS; $options['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE; $options['trace'] = true; $options['encoding'] = 'utf-8'; $options['login'] = $webservice->login; $options['password'] = $webservice->password; $client = new SoapClient($wsdl, $options); //Set Soap Headers $header = new stdClass(); $header->ConsumerId = $this->wsService->header->ConsumerId; $header->CustomerId = ($this->customerId===null) ? $this->wsService->header->CustomerId : $this->customerId ; $header->Provider = new stdClass(); $header->Provider->ProviderId = $this->ProviderId; $header->Provider->CountryCode = $this->CountryCode; $header->TimeStamp = time(); $header->TestIndication = $test; $soapheader = new SoapHeader( $webservice->{$webservice}->header->namespace, $webservice->{$webservice}->header->serviceName, $header ); $client->__setSoapHeaders($soapheader); return $client; } /** * Gestion des erreurs soap provenant de giant */ protected function soaperror($method, $fault, $requete, $reponse) { return false; } }