Files
kopalnia_2014/20210926_soap.php
2026-09-03 11:24:19 +02:00

230 lines
6.2 KiB
PHP

<?php
class SyndisConnector {
private $client;
private function objectToArray($d) {
if(is_object($d)) {
$d = get_object_vars($d);
}
if(is_array($d)) {
return array_map(__METHOD__, $d); // recursive
} else {
return $d;
}
}
public function __construct($url){
if(!isset($url) || empty($url)) throw new Exception ("Cannot create SYNDISconnector without provided url");
$this->client = new SoapClient($url, array('trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE)
);
}
public function __debug(){
echo "Request:\n" . $this->client->__getLastRequest() . "\n";
echo "Response:\n" . $this->client->__getLastResponse() . "\n";
}
public function __setLocation($location){
$this->client->__setLocation($location);
}
public function __getFunctions(){
var_dump($this->client->__getFunctions());
}
/**
*
*
*/
public function GetWellData($id) {
if(@function_exists($this->client->GetWellData)) throw new Exception("Provided endpoint does not contain GetWellData function. Please contact with SYNDIS support");
if(!isset($id) || empty($id)) throw new Exception("id param cannot be null or empty");
return $this->client->GetWellData(array('id' => $id));
}
/**
*
*
*/
public function GetWellDataAsArray($id) {
return $this->objectToArray($this->GetWellData($id));
}
/**
*
*
*/
public function GetWellsData($ids = array()) {
if(@function_exists($this->client->GetWellsData)) throw new Exception("Provided endpoint does not contain GetWellsData function. Please contact with SYNDIS support");
if(count($ids) < 1) throw new Exception("ids param cannot be empty array");
$idsArray = array();
foreach($ids as $id){
$idsArray[] = array('id' => $id);
}
return $this->client->GetWellsData($idsArray);
}
/**
*
*
*/
public function GetWellsDataAsArray($ids) {
return $this->objectToArray($this->GetWellsData($ids));
}
/**
*
*
*/
public function GetPiezometerData($id){
if(@function_exists($this->client->GetPiezometerData)) throw new Exception("Provided endpoint does not contain GetPiezometerData function. Please contact with SYNDIS support");
if(!isset($id) || empty($id)) throw new Exception("id param cannot be null or empty");
return $this->client->GetPiezometerData(array('id' => $id));
}
/**
*
*
*/
public function GetPiezometerDataAsArray($id) {
return $this->objectToArray($this->GetPiezometerData($id));
}
/**
*
*
*/
public function GetPiezometersData($ids){
if(@function_exists($this->client->GetPiezometersData)) throw new Exception("Provided endpoint does not contain GetPiezometersData function. Please contact with SYNDIS support");
if(count($ids) < 1) throw new Exception("ids param cannot be empty array");
$idsArray = array();
foreach($ids as $id){
$idsArray[] = array('id' => $id);
}
return $this->client->GetPiezometersData($idsArray);
}
/**
*
*
*/
public function GetPiezometersDataAsArray($ids) {
return $this->objectToArray($this->GetPiezometersData($ids));
}
/**
*
*
*/
public function GetUserInfo($login){
if(@function_exists($this->client->GetUserInfo)) throw new Exception("Provided endpoint does not contain GetUserInfo function. Please contact with SYNDIS support");
if(!isset($login) || empty($login)) throw new Exception("login param cannot be null or empty");
return $this->client->GetUserInfo(array('login' => $login));
}
/**
*
*
*/
public function GetUserInfoAsArray($ids) {
return $this->objectToArray($this->GetUserInfo($ids));
}
/**
*
*
*/
public function GetUserInfos($logins){
if(@function_exists($this->client->GetUserInfos)) throw new Exception("Provided endpoint does not contain GetUserInfos function. Please contact with SYNDIS support");
if(count($logins) < 1) throw new Exception("logins param cannot be empty array");
$idsArray = array();
foreach($logins as $login){
$idsArray[] = array('login' => $login);
}
return $this->client->GetUserInfos($idsArray);
}
/**
*
*
*/
public function GetUserInfosAsArray($ids) {
return $this->objectToArray($this->GetUserInfos($ids));
}
/**
*
*
*/
public function GetFullUserInfos(){
if(@function_exists($this->client->GetUserInfos)) throw new Exception("Provided endpoint does not contain GetUserInfos function. Please contact with SYNDIS support");
return $this->client->GetUserInfos();
}
/**
*
*
*/
public function GetFullUserInfosAsArray() {
return $this->objectToArray($this->GetFullUserInfos());
}
// informacja na temat pomiaru sygnałów
public function GetPumpSwitchHistory($id,$dt) {
if(@function_exists($this->client->GetPumpSwitchHistory)) throw new Exception("Provided endpoint does not contain GetPumpSwitchHistory function. Please contact with SYNDIS support");
if(!isset($id) || empty($id)) throw new Exception("id param cannot be null or empty");
return $this->client->GetPumpSwitchHistory(array('well' => array('id'=>$id),'date'=>$dt));
}
// informacja na temat pomiaru sygnałów wraz z powodem wyłączenia
public function GetPumpSwitchAndReasonsHistory($id,$dt) {
if(@function_exists($this->client->GetPumpSwitchAndReasonsHistory)) throw new Exception("Provided endpoint does not contain GetPumpSwitchAndReasonsHistory function. Please contact with SYNDIS support");
if(!isset($id) || empty($id)) throw new Exception("id param cannot be null or empty");
return $this->client->GetPumpSwitchAndReasonsHistory(array('well' => array('id'=>$id),'filtered'=>1,'date'=>$dt));
}
}
?>