From da6367e4c4b35857fd3d1b47ddeb3e56098c7e98 Mon Sep 17 00:00:00 2001 From: Bo Roth Date: Thu, 20 Feb 2020 10:11:08 -0600 Subject: [PATCH 1/3] Adds .idea/ to .gitignore for PHPStorm/WebStorm IDE files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ec6658c5..2ffa2d62 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .project .buildpath +.idea/ /vendor /.settings \ No newline at end of file From 74d34ee4dbd78f22d2cd1693f05b0215f73791f1 Mon Sep 17 00:00:00 2001 From: Bo Roth Date: Thu, 20 Feb 2020 10:12:04 -0600 Subject: [PATCH 2/3] Allows adding parameters to the getRecord() api call. --- src/crm/api/handler/EntityAPIHandler.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/crm/api/handler/EntityAPIHandler.php b/src/crm/api/handler/EntityAPIHandler.php index e2b59b6c..4ab0e63d 100644 --- a/src/crm/api/handler/EntityAPIHandler.php +++ b/src/crm/api/handler/EntityAPIHandler.php @@ -28,13 +28,16 @@ public static function getInstance($zcrmrecord) { return new EntityAPIHandler($zcrmrecord); } - - public function getRecord() + + public function getRecord(array $params = null) { try { $this->requestMethod = APIConstants::REQUEST_METHOD_GET; $this->urlPath = $this->record->getModuleApiName() . "/" . $this->record->getEntityId(); $this->addHeader("Content-Type", "application/json"); + if (!is_null($params)) { + $this->setRequestParams($params); + } $responseInstance = APIRequest::getInstance($this)->getAPIResponse(); $recordDetails = $responseInstance->getResponseJSON()['data']; self::setRecordProperties($recordDetails[0]); From 906ab8c538a7ba859139476af50eecfacd4c4aa9 Mon Sep 17 00:00:00 2001 From: Bo Roth Date: Thu, 20 Feb 2020 11:03:43 -0600 Subject: [PATCH 3/3] Simplify code --- src/crm/api/handler/EntityAPIHandler.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/crm/api/handler/EntityAPIHandler.php b/src/crm/api/handler/EntityAPIHandler.php index 4ab0e63d..9a0ea6ce 100644 --- a/src/crm/api/handler/EntityAPIHandler.php +++ b/src/crm/api/handler/EntityAPIHandler.php @@ -29,15 +29,13 @@ public static function getInstance($zcrmrecord) return new EntityAPIHandler($zcrmrecord); } - public function getRecord(array $params = null) + public function getRecord(array $params = array()) { try { $this->requestMethod = APIConstants::REQUEST_METHOD_GET; $this->urlPath = $this->record->getModuleApiName() . "/" . $this->record->getEntityId(); $this->addHeader("Content-Type", "application/json"); - if (!is_null($params)) { - $this->setRequestParams($params); - } + $this->setRequestParams($params); $responseInstance = APIRequest::getInstance($this)->getAPIResponse(); $recordDetails = $responseInstance->getResponseJSON()['data']; self::setRecordProperties($recordDetails[0]);