Skip to content

Commit 98212e6

Browse files
author
Dennis van den Heerik
committed
added employee authorization calls
1 parent 3c140d7 commit 98212e6

File tree

1 file changed

+193
-1
lines changed

1 file changed

+193
-1
lines changed

Mplusqapiclient.php

Lines changed: 193 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class MplusQAPIclient
44
{
5-
const CLIENT_VERSION = '1.27.8';
5+
const CLIENT_VERSION = '1.27.9';
66
const WSDL_TTL = 300;
77

88
var $MIN_API_VERSION_MAJOR = 0;
@@ -3449,6 +3449,106 @@ public function registerGiftcardPayment($cardNumber, $branchNumber, $employeeNum
34493449
}
34503450
}
34513451
// END registerGiftcardPayment()
3452+
3453+
//----------------------------------------------------------------------------
3454+
public function getEmployeeAuthorizations($employeeNumber, $branchNumber, $attempts = 0) {
3455+
try {
3456+
$request = $this->parser->convertGetEmployeeAuthorizationsRequest($employeeNumber, $branchNumber);
3457+
$result = $this->client->getEmployeeAuthorizations($request);
3458+
return $this->parser->parseGetEmployeeAuthorizationsResult($result);
3459+
} catch (SoapFault $e) {
3460+
$msg = $e->getMessage();
3461+
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
3462+
sleep(1);
3463+
return $this->getEmployeeAuthorizations($employeeNumber, $branchNumber, $attempts + 1);
3464+
} else {
3465+
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
3466+
}
3467+
} catch (Exception $e) {
3468+
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
3469+
}
3470+
}
3471+
3472+
// END getEmployeeAuthorizations()
3473+
//----------------------------------------------------------------------------
3474+
public function getGroupAuthorizations($groupNumber, $attempts = 0) {
3475+
try {
3476+
$request = $this->parser->convertGetGroupAuthorizationsRequest($groupNumber);
3477+
$result = $this->client->getGroupAuthorizations($request);
3478+
return $this->parser->parseGetGroupAuthorizationsResult($result);
3479+
} catch (SoapFault $e) {
3480+
$msg = $e->getMessage();
3481+
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
3482+
sleep(1);
3483+
return $this->getGroupAuthorizations($groupNumber, $attempts + 1);
3484+
} else {
3485+
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
3486+
}
3487+
} catch (Exception $e) {
3488+
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
3489+
}
3490+
}
3491+
3492+
// END getGroupAuthorizations()
3493+
//----------------------------------------------------------------------------
3494+
public function updateGroupAuthorizations($groupNumber, $authorizations, $attempts = 0) {
3495+
try {
3496+
$request = $this->parser->convertUpdateGroupAuthorizationsRequest($groupNumber, $authorizations);
3497+
$result = $this->client->updateGroupAuthorizations($request);
3498+
return $this->parser->parseUpdateGroupAuthorizationsResult($result);
3499+
} catch (SoapFault $e) {
3500+
$msg = $e->getMessage();
3501+
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
3502+
sleep(1);
3503+
return $this->updateGroupAuthorizations($groupNumber, $authorizations, $attempts + 1);
3504+
} else {
3505+
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
3506+
}
3507+
} catch (Exception $e) {
3508+
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
3509+
}
3510+
}
3511+
3512+
// END updateGroupAuthorizations()
3513+
//----------------------------------------------------------------------------
3514+
public function getAuthorizationGroups($attempts = 0) {
3515+
try {
3516+
$result = $this->client->getAuthorizationGroups();
3517+
return $this->parser->parseGetAuthorizationGroupsResult($result);
3518+
} catch (SoapFault $e) {
3519+
$msg = $e->getMessage();
3520+
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
3521+
sleep(1);
3522+
return $this->getAuthorizationGroups($attempts + 1);
3523+
} else {
3524+
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
3525+
}
3526+
} catch (Exception $e) {
3527+
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
3528+
}
3529+
}
3530+
3531+
// END getAuthorizationGroups()
3532+
3533+
//----------------------------------------------------------------------------
3534+
public function getAuthorizationTree($attempts = 0) {
3535+
try {
3536+
$result = $this->client->getAuthorizationTree();
3537+
return $this->parser->parseGetAuthorizationTreeResult($result);
3538+
} catch (SoapFault $e) {
3539+
$msg = $e->getMessage();
3540+
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
3541+
sleep(1);
3542+
return $this->getAuthorizationTree($attempts + 1);
3543+
} else {
3544+
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
3545+
}
3546+
} catch (Exception $e) {
3547+
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
3548+
}
3549+
}
3550+
3551+
// END getAuthorizationTree()
34523552
}
34533553

34543554
//==============================================================================
@@ -5955,6 +6055,67 @@ public function parseRegisterGiftcardPaymentResult($soapRegisterGiftcardPaymentR
59556055
}
59566056
// END parseRegisterGiftcardPaymentResult()
59576057

6058+
//----------------------------------------------------------------------------
6059+
public function parseGetEmployeeAuthorizationsResult($soapGetEmployeeAuthorizationsResult) {
6060+
if (property_exists($soapGetEmployeeAuthorizationsResult, "authorizationsList") &&
6061+
property_exists($soapGetEmployeeAuthorizationsResult->authorizationsList, "authorizations")) {
6062+
return $soapGetEmployeeAuthorizationsResult->authorizationsList->authorizations;
6063+
} else {
6064+
return false;
6065+
}
6066+
}
6067+
// END parseGetEmployeeAuthorizationsResult()
6068+
6069+
//----------------------------------------------------------------------------
6070+
public function parseGetGroupAuthorizationsResult($soapGetGroupAuthorizationsResult) {
6071+
if (property_exists($soapGetGroupAuthorizationsResult, "authorizationsList") &&
6072+
property_exists($soapGetGroupAuthorizationsResult->authorizationsList, "authorizations")) {
6073+
return $soapGetGroupAuthorizationsResult->authorizationsList->authorizations;
6074+
} else {
6075+
return false;
6076+
}
6077+
}
6078+
// END parseGetGroupAuthorizationsResult()
6079+
6080+
//----------------------------------------------------------------------------
6081+
public function parseUpdateGroupAuthorizationsResult($soapUpdateGroupAuthorizationsResult) {
6082+
if (property_exists($soapUpdateGroupAuthorizationsResult, "authorizationsList") &&
6083+
property_exists($soapUpdateGroupAuthorizationsResult->authorizationsList, "authorizations")) {
6084+
return $soapUpdateGroupAuthorizationsResult->authorizationsList->authorizations;
6085+
} else {
6086+
return false;
6087+
}
6088+
}
6089+
// END parseUpdateGroupAuthorizationsResult()
6090+
6091+
//----------------------------------------------------------------------------
6092+
public function parseGetAuthorizationGroupsResult($soapGetAuthorizationGroupsResult) {
6093+
if (property_exists($soapGetAuthorizationGroupsResult, "groupList") &&
6094+
property_exists($soapGetAuthorizationGroupsResult->groupList, "groups")) {
6095+
return $soapGetAuthorizationGroupsResult->groupList->groups;
6096+
} else {
6097+
return false;
6098+
}
6099+
}
6100+
// END parseGetAuthorizationTreeResult()
6101+
6102+
//----------------------------------------------------------------------------
6103+
public function parseGetAuthorizationTreeResult($soapGetAuthorizationTreeResult) {
6104+
if (property_exists($soapGetAuthorizationTreeResult, "backOfficeAuthorizationsList") &&
6105+
property_exists($soapGetAuthorizationTreeResult->backOfficeAuthorizationsList, "authorizations") &&
6106+
property_exists($soapGetAuthorizationTreeResult, "articleAuthorizationsList") &&
6107+
property_exists($soapGetAuthorizationTreeResult->articleAuthorizationsList, "authorizations") &&
6108+
property_exists($soapGetAuthorizationTreeResult, "relationAuthorizationsList") &&
6109+
property_exists($soapGetAuthorizationTreeResult->relationAuthorizationsList, "authorizations") &&
6110+
property_exists($soapGetAuthorizationTreeResult, "employeeAuthorizationsList") &&
6111+
property_exists($soapGetAuthorizationTreeResult->employeeAuthorizationsList, "authorizations")
6112+
) {
6113+
return $soapGetAuthorizationTreeResult;
6114+
} else {
6115+
return false;
6116+
}
6117+
}
6118+
// END parseGetAuthorizationTreeResult()
59586119

59596120
//----------------------------------------------------------------------------
59606121

@@ -8658,6 +8819,37 @@ public function convertRegisterGiftcardPaymentRequest($cardNumber, $branchNumber
86588819
return $object;
86598820
}
86608821
// END convertRegisterGiftcardPaymentRequest()
8822+
8823+
//----------------------------------------------------------------------------
8824+
public function convertGetEmployeeAuthorizationsRequest($employeeNumber, $branchNumber) {
8825+
$request = new stdClass();
8826+
$request->request = new stdClass();
8827+
$request->request->employeeNumber = $employeeNumber;
8828+
$request->request->branchNumber = $branchNumber;
8829+
return $request;
8830+
}
8831+
// END convertGetEmployeeAuthorizationsRequest()
8832+
8833+
//----------------------------------------------------------------------------
8834+
public function convertGetGroupAuthorizationsRequest($groupNumber) {
8835+
$request = new stdClass();
8836+
$request->request = new stdClass();
8837+
$request->request->groupNumber = $groupNumber;
8838+
return $request;
8839+
}
8840+
// END convertGetGroupAuthorizationsRequest()
8841+
8842+
//----------------------------------------------------------------------------
8843+
public function convertUpdateGroupAuthorizationsRequest($groupNumber, $authorizations) {
8844+
$request = new stdClass();
8845+
$request->request = new stdClass();
8846+
$request->request->groupNumber = $groupNumber;
8847+
$request->request->authorizationsList = new stdClass();
8848+
$request->request->authorizationsList->authorizations = $authorizations;
8849+
return $request;
8850+
}
8851+
// END convertUpdateGroupAuthorizationsRequest()
8852+
86618853
}
86628854

86638855
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)