diff --git a/core/restservices.class.inc.php b/core/restservices.class.inc.php index 025ae847e..8214975d0 100644 --- a/core/restservices.class.inc.php +++ b/core/restservices.class.inc.php @@ -36,15 +36,19 @@ class ObjectResult { public $code; public $message; + public $class; + public $key; public $fields; /** * Default constructor */ - public function __construct() + public function __construct($sClass = null, $iId = null) { $this->code = RestResult::OK; $this->message = ''; + $this->class = $sClass; + $this->key = $iId; $this->fields = array(); } @@ -144,11 +148,10 @@ class RestResultWithObjects extends RestResult */ public function AddObject($iCode, $sMessage, $oObject, $aFields) { - $oObjRes = new ObjectResult(); + $oObjRes = new ObjectResult(get_class($oObject), $oObject->GetKey()); $oObjRes->code = $iCode; $oObjRes->message = $sMessage; - $oObjRes->class = get_class($oObject); foreach ($aFields as $sAttCode) { $oObjRes->AddField($oObject, $sAttCode); @@ -233,8 +236,10 @@ class CoreServices implements iRestServiceProvider */ public function ListOperations($sVersion) { + // 1.1 - In the reply, objects have a 'key' entry so that it is no more necessary to split class::key programmaticaly + // $aOps = array(); - if ($sVersion == '1.0') + if (in_array($sVersion, array('1.0', '1.1'))) { $aOps[] = array( 'verb' => 'core/create', diff --git a/webservices/itoprest.examples.php b/webservices/itoprest.examples.php index 7d4d6b542..5935048a1 100644 --- a/webservices/itoprest.examples.php +++ b/webservices/itoprest.examples.php @@ -159,7 +159,15 @@ $aOperations = array( ), ); -$sUrl = "http://localhost/rest-services/webservices/rest.php?version=1.0"; +if (true) +{ + echo "Please edit the sample script and configure the server URL"; + exit; +} +else +{ + $sUrl = "http://localhost/trunk/webservices/rest.php?version=1.1"; +} $aData = array(); $aData['auth_user'] = 'admin';