Skip to content

Commit

Permalink
v1.19 - Added verifyCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
freerk-mpluskassa committed Aug 14, 2019
1 parent c622343 commit 21f82a0
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions Mplusqapiclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -8189,6 +8224,14 @@ public function convertButtonLayoutRequest($terminal)
} // END convertButtonLayoutRequest()

//----------------------------------------------------------------------------

public function convertVerifyCredentialsRequest($request)
{
$object = arrayToObject(['request'=>$request]);
return $object;
}

//----------------------------------------------------------------------------
}

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 21f82a0

Please sign in to comment.