2
2
3
3
class MplusQAPIclient
4
4
{
5
- const CLIENT_VERSION = '1.7 .0 ' ;
5
+ const CLIENT_VERSION = '1.8 .0 ' ;
6
6
7
7
8
8
var $ MIN_API_VERSION_MAJOR = 0 ;
@@ -2504,45 +2504,79 @@ public function getTableOrderCourseList($terminal, $branchNumber, $tableNumber,
2504
2504
2505
2505
//----------------------------------------------------------------------------
2506
2506
2507
- public function saveTableOrder ($ terminal , $ order )
2507
+ public function saveTableOrder ($ terminal , $ order, $ attempts = 0 )
2508
2508
{
2509
2509
try {
2510
2510
$ result = $ this ->client ->saveTableOrder ($ this ->parser ->convertSaveTableOrder ($ terminal , $ order ));
2511
2511
return $ this ->parser ->parseSaveTableOrderResult ($ result );
2512
2512
} catch (SoapFault $ e ) {
2513
- throw new MplusQAPIException ('SoapFault occurred: ' .$ e ->getMessage (), 0 , $ e );
2513
+ $ msg = $ e ->getMessage ();
2514
+ if (false !== stripos ($ msg , 'Could not connect to host ' ) and $ attempts < 3 ) {
2515
+ sleep (1 );
2516
+ return $ this ->saveTableOrder ($ terminal , $ order , $ attempts +1 );
2517
+ } else {
2518
+ throw new MplusQAPIException ('SoapFault occurred: ' .$ msg , 0 , $ e );
2519
+ }
2514
2520
} catch (Exception $ e ) {
2515
2521
throw new MplusQAPIException ('Exception occurred: ' .$ e ->getMessage (), 0 , $ e );
2516
2522
}
2517
2523
} // END getTableOrder()
2518
2524
2519
2525
//----------------------------------------------------------------------------
2520
2526
2521
- public function cancelTableOrder ($ terminal , $ branchNumber , $ tableNumber )
2527
+ public function moveTableOrder ($ terminal , $ order , $ tableNumber , $ attempts =0 )
2528
+ {
2529
+ try {
2530
+ $ result = $ this ->client ->moveTableOrder ($ this ->parser ->convertMoveTableOrderRequest ($ terminal , $ order , $ tableNumber ));
2531
+ return $ this ->parser ->parseMoveTableOrderResult ($ result );
2532
+ } catch (SoapFault $ e ) {
2533
+ $ msg = $ e ->getMessage ();
2534
+ if (false !== stripos ($ msg , 'Could not connect to host ' ) and $ attempts < 3 ) {
2535
+ sleep (1 );
2536
+ return $ this ->moveTableOrder ($ terminal , $ order , $ tableNumber , $ attempts +1 );
2537
+ } else {
2538
+ throw new MplusQAPIException ('SoapFault occurred: ' .$ msg , 0 , $ e );
2539
+ }
2540
+ } catch (Exception $ e ) {
2541
+ throw new MplusQAPIException ('Exception occurred: ' .$ e ->getMessage (), 0 , $ e );
2542
+ }
2543
+ } // END cancelTableOrder()
2544
+
2545
+ //----------------------------------------------------------------------------
2546
+
2547
+ public function cancelTableOrder ($ terminal , $ branchNumber , $ tableNumber , $ attempts =0 )
2522
2548
{
2523
2549
try {
2524
2550
$ result = $ this ->client ->cancelTableOrder ($ this ->parser ->convertGetTableOrderRequest ($ terminal , $ branchNumber , $ tableNumber ));
2525
2551
return $ this ->parser ->parseCancelOrderResult ($ result );
2526
2552
} catch (SoapFault $ e ) {
2527
- throw new MplusQAPIException ('SoapFault occurred: ' .$ e ->getMessage (), 0 , $ e );
2553
+ $ msg = $ e ->getMessage ();
2554
+ if (false !== stripos ($ msg , 'Could not connect to host ' ) and $ attempts < 3 ) {
2555
+ sleep (1 );
2556
+ return $ this ->cancelTableOrder ($ terminal , $ branchNumber , $ tableNumber , $ attempts +1 );
2557
+ } else {
2558
+ throw new MplusQAPIException ('SoapFault occurred: ' .$ msg , 0 , $ e );
2559
+ }
2528
2560
} catch (Exception $ e ) {
2529
2561
throw new MplusQAPIException ('Exception occurred: ' .$ e ->getMessage (), 0 , $ e );
2530
2562
}
2531
2563
} // END cancelTableOrder()
2532
2564
2533
2565
//----------------------------------------------------------------------------
2534
2566
2535
- public function sendMessage ($ branchNumber , $ terminalNumber , $ text , $ sender =null , $ messageType =null )
2567
+ public function sendMessage ($ branchNumber , $ terminalNumber , $ text , $ sender =null , $ messageType =null , $ attempts = 0 )
2536
2568
{
2537
2569
try {
2538
2570
$ forceBranchTerminalNumber = $ this ->isApiVersionLowerThan ('1.0.0 ' );
2539
2571
$ result = $ this ->client ->sendMessage ($ this ->parser ->convertSendMessageRequest ($ branchNumber , $ terminalNumber , $ text , $ sender , $ messageType , $ forceBranchTerminalNumber ));
2540
2572
return $ this ->parser ->parseSendMessageResult ($ result );
2541
2573
} catch (SoapFault $ e ) {
2542
- if (false !== stripos ($ e ->getMessage (), "object has no 'branchNumber' property " ) and ! $ forceBranchTerminalNumber ) {
2543
- return $ this ->sendMessage ($ branchNumber , $ terminalNumber , $ text , $ sender , $ messageType , true );
2574
+ $ msg = $ e ->getMessage ();
2575
+ if (false !== stripos ($ msg , 'Could not connect to host ' ) and $ attempts < 3 ) {
2576
+ sleep (1 );
2577
+ return $ this ->sendMessage ($ branchNumber , $ terminalNumber , $ text , $ sender , $ messageType , $ attempts +1 );
2544
2578
} else {
2545
- throw new MplusQAPIException ('SoapFault occurred: ' .$ e -> getMessage () , 0 , $ e );
2579
+ throw new MplusQAPIException ('SoapFault occurred: ' .$ msg , 0 , $ e );
2546
2580
}
2547
2581
} catch (Exception $ e ) {
2548
2582
throw new MplusQAPIException ('Exception occurred: ' .$ e ->getMessage (), 0 , $ e );
@@ -2551,13 +2585,19 @@ public function sendMessage($branchNumber, $terminalNumber, $text, $sender=null,
2551
2585
2552
2586
//----------------------------------------------------------------------------
2553
2587
2554
- public function encryptString ($ plainString , $ encryptionKey )
2588
+ public function encryptString ($ plainString , $ encryptionKey, $ attempts = 0 )
2555
2589
{
2556
2590
try {
2557
2591
$ result = $ this ->client ->encryptString ($ this ->parser ->convertEncryptStringRequest ($ plainString , $ encryptionKey ));
2558
2592
return $ this ->parser ->parseEncryptStringResult ($ result );
2559
2593
} catch (SoapFault $ e ) {
2560
- throw new MplusQAPIException ('SoapFault occurred: ' .$ e ->getMessage (), 0 , $ e );
2594
+ $ msg = $ e ->getMessage ();
2595
+ if (false !== stripos ($ msg , 'Could not connect to host ' ) and $ attempts < 3 ) {
2596
+ sleep (1 );
2597
+ return $ this ->encryptString ($ plainString , $ encryptionKey , $ attempts +1 );
2598
+ } else {
2599
+ throw new MplusQAPIException ('SoapFault occurred: ' .$ msg , 0 , $ e );
2600
+ }
2561
2601
} catch (Exception $ e ) {
2562
2602
throw new MplusQAPIException ('Exception occurred: ' .$ e ->getMessage (), 0 , $ e );
2563
2603
}
@@ -4152,6 +4192,8 @@ public function parseRegisterTerminalResult($soapRegisterTerminalResult)
4152
4192
public function parseUpdateOrderResult ($ soapUpdateOrderResult ) {
4153
4193
if (isset ($ soapUpdateOrderResult ->result ) and $ soapUpdateOrderResult ->result == 'UPDATE-ORDER-RESULT-OK ' ) {
4154
4194
return true ;
4195
+ } else if (isset ($ soapUpdateOrderResult ->result ) and $ soapUpdateOrderResult ->result == 'UPDATE-ORDER-RESULT-FAILED ' and $ soapUpdateOrderResult ->errorMessage == 'Order not saved because there were no changes in the order. ' ) {
4196
+ return true ;
4155
4197
} else {
4156
4198
if ( ! empty ($ soapUpdateOrderResult ->errorMessage )) {
4157
4199
$ this ->lastErrorMessage = $ soapUpdateOrderResult ->errorMessage ;
@@ -4212,6 +4254,21 @@ public function parseQueueBranchOrderResult($soapQueueBranchOrderResult)
4212
4254
4213
4255
//----------------------------------------------------------------------------
4214
4256
4257
+ public function parseMoveTableOrderResult ($ soapMoveTableOrderResult )
4258
+ {
4259
+ if (isset ($ soapMoveTableOrderResult ->result ) and $ soapMoveTableOrderResult ->result == 'MOVE-TABLE-ORDER-RESULT-OK ' ) {
4260
+ return true ;
4261
+ } else {
4262
+ if (isset ($ soapMoveTableOrderResult ->errorMessage )) {
4263
+ return $ soapMoveTableOrderResult ->errorMessage ;
4264
+ } else {
4265
+ return false ;
4266
+ }
4267
+ }
4268
+ } // END parseMoveTableOrderResult()
4269
+
4270
+ //----------------------------------------------------------------------------
4271
+
4215
4272
public function parseCancelOrderResult ($ soapCancelOrderResult )
4216
4273
{
4217
4274
if (isset ($ soapCancelOrderResult ->result ) and $ soapCancelOrderResult ->result == 'CANCEL-ORDER-RESULT-OK ' ) {
@@ -6421,6 +6478,20 @@ public function convertSaveTableOrder($terminal, $order)
6421
6478
6422
6479
//----------------------------------------------------------------------------
6423
6480
6481
+ public function convertMoveTableOrderRequest ($ terminal , $ order , $ tableNumber )
6482
+ {
6483
+ $ terminal = $ this ->convertTerminal ($ terminal );
6484
+ $ order = $ this ->convertOrder ($ order );
6485
+ $ object = arrayToObject (array (
6486
+ 'terminal ' =>$ terminal ->terminal ,
6487
+ 'order ' =>$ order ->order ,
6488
+ 'tableNumber ' =>$ tableNumber ,
6489
+ ));
6490
+ return $ object ;
6491
+ } // END convertMoveTableOrderRequest()
6492
+
6493
+ //----------------------------------------------------------------------------
6494
+
6424
6495
public function convertBranchNumber ($ branchNumber )
6425
6496
{
6426
6497
$ object = arrayToObject (array ('branchNumber ' =>$ branchNumber ));
0 commit comments