diff --git a/src/Vtiger.php b/src/Vtiger.php index 710d5ab..f6819de 100644 --- a/src/Vtiger.php +++ b/src/Vtiger.php @@ -231,4 +231,31 @@ public function update($object) return (isset($data->success)) ? $data : false; } + + public function describe($elementType) + { + $sessionid = self::sessionid(); + + if (isset($sessionid->success)) { + return $sessionid->message; + } + + for ($i = 0; (!isset($data->success) && $i < 10); $i++) { + // send a request to describe a module (which returns a list of available fields) for a Vtiger module + $response = $this->client->request('GET', $this->url, [ + 'query' => [ + 'operation' => 'describe', + 'sessionName' => $sessionid, + 'elementType' => $elementType + ] + ]); + + // decode the response + $data = json_decode($response->getBody()->getContents()); + } + + self::close($sessionid); + + return (isset($data->success)) ? $data : false; + } }