From 21f82a0162e41168ebeede2e22d53b82c4a5f82f Mon Sep 17 00:00:00 2001 From: Freerk Minnema Date: Wed, 14 Aug 2019 13:47:34 +0200 Subject: [PATCH] v1.19 - Added verifyCredentials --- Mplusqapiclient.php | 47 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/Mplusqapiclient.php b/Mplusqapiclient.php index 381f394..90bfd7f 100755 --- a/Mplusqapiclient.php +++ b/Mplusqapiclient.php @@ -2,7 +2,7 @@ class MplusQAPIclient { - const CLIENT_VERSION = '1.18.2'; + const CLIENT_VERSION = '1.19.0'; const WSDL_TTL = 300; // 5 min WSDL TTL var $MIN_API_VERSION_MAJOR = 0; @@ -3216,7 +3216,28 @@ public function deleteActivity($activityId, $attempts=0) } } // END deleteActivity() -//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- + + public function verifyCredentials($request, $attempts=0) + { + try { + $result = $this->client->verifyCredentials($this->parser->convertVerifyCredentialsRequest($request)); + return $this->parser->parseVerifyCredentialsResult($result); + } catch (SoapFault $e) { + $msg = $e->getMessage(); + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { + sleep(1); + return $this->verifyCredentials($activityId, $attempts+1); + } else { + throw new MplusQAPIException('SoapFault occurred: '.$msg, 0, $e); + } + } catch (Exception $e) { + throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e); + } + } + + //---------------------------------------------------------------------------- + public function report($arguments, $attempts = 0) { try { @@ -5587,6 +5608,20 @@ public function parseDeleteActivityResult($in) return $result; } // END parseDeleteActivityResult() + //---------------------------------------------------------------------------- + + public function parseVerifyCredentialsResult($in) + { + if (isset($in->verified)) { + $parsed = ['verified'=>$in->verified]; + if (isset($in->employee)) { + $parsed['employee'] = objectToArray($in->employee); + } + return $parsed; + } + return false; + } + //---------------------------------------------------------------------------- public function parseReportResult($method, $soapReportResult) { @@ -8189,6 +8224,14 @@ public function convertButtonLayoutRequest($terminal) } // END convertButtonLayoutRequest() //---------------------------------------------------------------------------- + + public function convertVerifyCredentialsRequest($request) + { + $object = arrayToObject(['request'=>$request]); + return $object; + } + + //---------------------------------------------------------------------------- } //------------------------------------------------------------------------------