|
2 | 2 |
|
3 | 3 | class MplusQAPIclient |
4 | 4 | { |
5 | | - const CLIENT_VERSION = '1.28.0'; |
| 5 | + const CLIENT_VERSION = '1.28.1'; |
6 | 6 | const WSDL_TTL = 300; |
7 | 7 |
|
8 | 8 | var $MIN_API_VERSION_MAJOR = 0; |
@@ -3565,6 +3565,126 @@ public function updateOrderV2($order) { |
3565 | 3565 | } |
3566 | 3566 | } |
3567 | 3567 | // END updateOrderV2() |
| 3568 | + |
| 3569 | + //---------------------------------------------------------------------------- |
| 3570 | + public function getGiftcard($cardNumber = null, $cardId = null, $attempts = 0) { |
| 3571 | + try { |
| 3572 | + $request = $this->parser->convertGetGiftcardRequest($cardNumber, $cardId); |
| 3573 | + $result = $this->client->getGiftcard($request); |
| 3574 | + return $this->parser->parseGetGiftcardResult($result); |
| 3575 | + } catch (SoapFault $e) { |
| 3576 | + $msg = $e->getMessage(); |
| 3577 | + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { |
| 3578 | + sleep(1); |
| 3579 | + return $this->getGiftcard($cardNumber, $cardId, $attempts + 1); |
| 3580 | + } else { |
| 3581 | + throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e); |
| 3582 | + } |
| 3583 | + } catch (Exception $e) { |
| 3584 | + throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e); |
| 3585 | + } |
| 3586 | + } |
| 3587 | + // END getGiftcard() |
| 3588 | + |
| 3589 | + //---------------------------------------------------------------------------- |
| 3590 | + public function getGiftcardHistory($cardNumber = null, $cardId = null, $attempts = 0) { |
| 3591 | + try { |
| 3592 | + $request = $this->parser->convertGetGiftcardHistoryRequest($cardNumber, $cardId); |
| 3593 | + $result = $this->client->getGiftcardHistory($request); |
| 3594 | + return $this->parser->parseGetGiftcardHistoryResult($result); |
| 3595 | + } catch (SoapFault $e) { |
| 3596 | + $msg = $e->getMessage(); |
| 3597 | + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { |
| 3598 | + sleep(1); |
| 3599 | + return $this->getGiftcardHistory($cardNumber, $cardId, $attempts + 1); |
| 3600 | + } else { |
| 3601 | + throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e); |
| 3602 | + } |
| 3603 | + } catch (Exception $e) { |
| 3604 | + throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e); |
| 3605 | + } |
| 3606 | + } |
| 3607 | + // END getGiftcardHistory() |
| 3608 | + |
| 3609 | + //---------------------------------------------------------------------------- |
| 3610 | + public function createGiftcard($cardNumber, $cardTypeId, $branchNumber, $employeeNumber, $amount, $externalReference, $relationNumber = null, $attempts = 0) { |
| 3611 | + try { |
| 3612 | + $request = $this->parser->convertCreateGiftcardRequest($cardNumber, $cardTypeId, $branchNumber, $employeeNumber, $amount, $externalReference, $relationNumber); |
| 3613 | + $result = $this->client->createGiftcard($request); |
| 3614 | + return $this->parser->parseCreateGiftcardResult($result); |
| 3615 | + } catch (SoapFault $e) { |
| 3616 | + $msg = $e->getMessage(); |
| 3617 | + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { |
| 3618 | + sleep(1); |
| 3619 | + return $this->createGiftcard($cardNumber, $cardTypeId, $branchNumber, $employeeNumber, $amount, $externalReference, $relationNumber, $attempts + 1); |
| 3620 | + } else { |
| 3621 | + throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e); |
| 3622 | + } |
| 3623 | + } catch (Exception $e) { |
| 3624 | + throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e); |
| 3625 | + } |
| 3626 | + } |
| 3627 | + // END createGiftcard() |
| 3628 | + |
| 3629 | + //---------------------------------------------------------------------------- |
| 3630 | + public function getGiftcardTypes($branchNumber, $attempts = 0) { |
| 3631 | + try { |
| 3632 | + $request = $this->parser->convertGetGiftcardTypesRequest($branchNumber); |
| 3633 | + $result = $this->client->getGiftcardTypes($request); |
| 3634 | + return $this->parser->parseGetGiftcardTypesResult($result); |
| 3635 | + } catch (SoapFault $e) { |
| 3636 | + $msg = $e->getMessage(); |
| 3637 | + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { |
| 3638 | + sleep(1); |
| 3639 | + return $this->getGiftcardTypes($branchNumber, $attempts + 1); |
| 3640 | + } else { |
| 3641 | + throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e); |
| 3642 | + } |
| 3643 | + } catch (Exception $e) { |
| 3644 | + throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e); |
| 3645 | + } |
| 3646 | + } |
| 3647 | + // END getGiftcardTypes() |
| 3648 | + |
| 3649 | + //---------------------------------------------------------------------------- |
| 3650 | + public function getRelationGiftcards($relationNumber, $attempts = 0) { |
| 3651 | + try { |
| 3652 | + $request = $this->parser->convertGetRelationGiftcardsRequest($relationNumber); |
| 3653 | + $result = $this->client->getRelationGiftcards($request); |
| 3654 | + return $this->parser->parseGetRelationGiftcardsResult($result); |
| 3655 | + } catch (SoapFault $e) { |
| 3656 | + $msg = $e->getMessage(); |
| 3657 | + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { |
| 3658 | + sleep(1); |
| 3659 | + return $this->getRelationGiftcards($relationNumber, $attempts + 1); |
| 3660 | + } else { |
| 3661 | + throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e); |
| 3662 | + } |
| 3663 | + } catch (Exception $e) { |
| 3664 | + throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e); |
| 3665 | + } |
| 3666 | + } |
| 3667 | + // END getRelationGiftcards() |
| 3668 | + |
| 3669 | + //---------------------------------------------------------------------------- |
| 3670 | + public function reloadGiftcard($cardNumber, $branchNumber, $employeeNumber, $amount, $externalReference, $attempts = 0) { |
| 3671 | + try { |
| 3672 | + $request = $this->parser->convertReloadGiftcardRequest($cardNumber, $branchNumber, $employeeNumber, $amount, $externalReference); |
| 3673 | + $result = $this->client->reloadGiftcard($request); |
| 3674 | + return $this->parser->parseReloadGiftcardResult($result); |
| 3675 | + } catch (SoapFault $e) { |
| 3676 | + $msg = $e->getMessage(); |
| 3677 | + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { |
| 3678 | + sleep(1); |
| 3679 | + return $this->reloadGiftcard($cardNumber, $branchNumber, $employeeNumber, $amount, $externalReference, $attempts + 1); |
| 3680 | + } else { |
| 3681 | + throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e); |
| 3682 | + } |
| 3683 | + } catch (Exception $e) { |
| 3684 | + throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e); |
| 3685 | + } |
| 3686 | + } |
| 3687 | + // END reloadGiftcard() |
3568 | 3688 | } |
3569 | 3689 |
|
3570 | 3690 | //============================================================================== |
@@ -6146,6 +6266,61 @@ public function parseUpdateOrderV2Result($soapUpdateOrderV2Result) { |
6146 | 6266 | } |
6147 | 6267 | } |
6148 | 6268 | // END parseUpdateOrderV2Result() |
| 6269 | + |
| 6270 | + //---------------------------------------------------------------------------- |
| 6271 | + public function parseGetGiftcardTypesResult($soapGetGiftcardTypesResult) { |
| 6272 | + if (property_exists($soapGetGiftcardTypesResult, "giftcardTypesList") && |
| 6273 | + property_exists($soapGetGiftcardTypesResult->giftcardTypesList, "giftcardTypes")) { |
| 6274 | + return $soapGetGiftcardTypesResult->giftcardTypesList->giftcardTypes; |
| 6275 | + } else { |
| 6276 | + return false; |
| 6277 | + } |
| 6278 | + } |
| 6279 | + // END parseGetGiftcardTypesResult() |
| 6280 | + |
| 6281 | + //---------------------------------------------------------------------------- |
| 6282 | + public function parseGetRelationGiftcardsResult($soapGetRelationGiftcardsResult) { |
| 6283 | + if (property_exists($soapGetRelationGiftcardsResult, "relationGiftcardList") && |
| 6284 | + property_exists($soapGetRelationGiftcardsResult->relationGiftcardList, "relationGiftcards")) { |
| 6285 | + return $soapGetRelationGiftcardsResult->relationGiftcardList->relationGiftcards; |
| 6286 | + } else { |
| 6287 | + return false; |
| 6288 | + } |
| 6289 | + } |
| 6290 | + // END parseGetGiftcardTypesResult() |
| 6291 | + |
| 6292 | + //---------------------------------------------------------------------------- |
| 6293 | + public function parseCreateGiftcardResult($soapCreateGiftcardResult) { |
| 6294 | + return $soapCreateGiftcardResult; |
| 6295 | + } |
| 6296 | + // END parseCreateGiftcardResult() |
| 6297 | + |
| 6298 | + //---------------------------------------------------------------------------- |
| 6299 | + public function parseReloadGiftcardResult($soapReloadGiftcardResult) { |
| 6300 | + return $soapReloadGiftcardResult; |
| 6301 | + } |
| 6302 | + // END parseReloadGiftcardResult() |
| 6303 | + |
| 6304 | + //---------------------------------------------------------------------------- |
| 6305 | + public function parseGetGiftcardResult($soapGetGiftcardResult) { |
| 6306 | + if (property_exists($soapGetGiftcardResult, "giftcard")) { |
| 6307 | + return $soapGetGiftcardResult->giftcard; |
| 6308 | + } else { |
| 6309 | + return false; |
| 6310 | + } |
| 6311 | + } |
| 6312 | + // END parseGetGiftcardResult() |
| 6313 | + |
| 6314 | + //---------------------------------------------------------------------------- |
| 6315 | + public function parseGetGiftcardHistoryResult($soapGetGiftcardHistoryResult) { |
| 6316 | + if (property_exists($soapGetGiftcardHistoryResult, "giftcardHistoryList") && |
| 6317 | + property_exists($soapGetGiftcardHistoryResult->giftcardHistoryList, "giftcardHistory")) { |
| 6318 | + return $soapGetGiftcardHistoryResult->giftcardHistoryList->giftcardHistory; |
| 6319 | + } else { |
| 6320 | + return false; |
| 6321 | + } |
| 6322 | + } |
| 6323 | + // END parseGetGiftcardHistoryResult() |
6149 | 6324 |
|
6150 | 6325 | //---------------------------------------------------------------------------- |
6151 | 6326 |
|
@@ -8909,6 +9084,82 @@ public function convertUpdateOrderV2($order, $applySalesAndActions = null, $appl |
8909 | 9084 | } |
8910 | 9085 | // END convertUpdateOrderV2() |
8911 | 9086 |
|
| 9087 | + //---------------------------------------------------------------------------- |
| 9088 | + public function convertGetGiftcardTypesRequest($branchNumber) { |
| 9089 | + $request = new stdClass(); |
| 9090 | + $request->request = new stdClass(); |
| 9091 | + $request->request->branchNumber = $branchNumber; |
| 9092 | + return $request; |
| 9093 | + } |
| 9094 | + // END convertGetGiftcardTypesRequest() |
| 9095 | + |
| 9096 | + //---------------------------------------------------------------------------- |
| 9097 | + public function convertGetRelationGiftcardsRequest($relationNumber) { |
| 9098 | + $request = new stdClass(); |
| 9099 | + $request->request = new stdClass(); |
| 9100 | + $request->request->relationNumber = $relationNumber; |
| 9101 | + return $request; |
| 9102 | + } |
| 9103 | + // END convertGetRelationGiftcardsRequest() |
| 9104 | + |
| 9105 | + //---------------------------------------------------------------------------- |
| 9106 | + public function convertCreateGiftcardRequest($cardNumber, $cardTypeId, $branchNumber, $employeeNumber, $amount, $externalReference, $relationNumber) { |
| 9107 | + $request = new stdClass(); |
| 9108 | + $request->request = new stdClass(); |
| 9109 | + $request->request->cardNumber = $cardNumber; |
| 9110 | + $request->request->cardTypeId = $cardTypeId; |
| 9111 | + $request->request->branchNumber = $branchNumber; |
| 9112 | + $request->request->employeeNumber = $employeeNumber; |
| 9113 | + $request->request->amount = $amount; |
| 9114 | + $request->request->externalReference = $externalReference; |
| 9115 | + if ($relationNumber !== null) { |
| 9116 | + $request->request->relationNumber = $relationNumber; |
| 9117 | + } |
| 9118 | + return $request; |
| 9119 | + } |
| 9120 | + // END convertCreateGiftcardRequest() |
| 9121 | + |
| 9122 | + //---------------------------------------------------------------------------- |
| 9123 | + public function convertReloadGiftcardRequest($cardNumber, $branchNumber, $employeeNumber, $amount, $externalReference) { |
| 9124 | + $request = new stdClass(); |
| 9125 | + $request->request = new stdClass(); |
| 9126 | + $request->request->cardNumber = $cardNumber; |
| 9127 | + $request->request->branchNumber = $branchNumber; |
| 9128 | + $request->request->employeeNumber = $employeeNumber; |
| 9129 | + $request->request->amount = $amount; |
| 9130 | + $request->request->externalReference = $externalReference; |
| 9131 | + return $request; |
| 9132 | + } |
| 9133 | + // END convertReloadGiftcardRequest() |
| 9134 | + |
| 9135 | + //---------------------------------------------------------------------------- |
| 9136 | + public function convertGetGiftcardRequest($cardNumber, $cardId) { |
| 9137 | + $request = new stdClass(); |
| 9138 | + $request->request = new stdClass(); |
| 9139 | + if ($cardNumber !== null) { |
| 9140 | + $request->request->cardNumber = $cardNumber; |
| 9141 | + } |
| 9142 | + if ($cardId !== null) { |
| 9143 | + $request->request->cardId = $cardId; |
| 9144 | + } |
| 9145 | + return $request; |
| 9146 | + } |
| 9147 | + // END convertGetGiftcardRequest() |
| 9148 | + |
| 9149 | + //---------------------------------------------------------------------------- |
| 9150 | + public function convertGetGiftcardHistoryRequest($cardNumber, $cardId) { |
| 9151 | + $request = new stdClass(); |
| 9152 | + $request->request = new stdClass(); |
| 9153 | + if ($cardNumber !== null) { |
| 9154 | + $request->request->cardNumber = $cardNumber; |
| 9155 | + } |
| 9156 | + if ($cardId !== null) { |
| 9157 | + $request->request->cardId = $cardId; |
| 9158 | + } |
| 9159 | + return $request; |
| 9160 | + } |
| 9161 | + // END convertGetGiftcardHistoryRequest() |
| 9162 | + |
8912 | 9163 | } |
8913 | 9164 |
|
8914 | 9165 | //------------------------------------------------------------------------------ |
|
0 commit comments