From 3e8048bc5281f49fffc84e24bc8a256018babf28 Mon Sep 17 00:00:00 2001 From: Clyde Cox Date: Tue, 24 Apr 2018 13:55:06 -0400 Subject: [PATCH] -Add describe function Added a describe function which runs a Vtiger API call to describe the elements(available fields) within a Vtiger module. --- src/Vtiger.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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; + } }