Skip to content

Commit 18088d4

Browse files
author
Dennis van den Heerik
committed
-cancelOrder has an optional argument which is required for future
cancelling of branch orders. -added updateOrderV2 api call
1 parent 98212e6 commit 18088d4

File tree

1 file changed

+78
-19
lines changed

1 file changed

+78
-19
lines changed

Mplusqapiclient.php

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

88
var $MIN_API_VERSION_MAJOR = 0;
@@ -2673,26 +2673,26 @@ function() use ($request) {
26732673
}
26742674
);
26752675
}
2676+
26762677
//----------------------------------------------------------------------------
2677-
2678-
public function cancelOrder($orderId, $attempts=0)
2679-
{
2680-
try {
2681-
if (false !== ($result = $this->client->cancelOrder($this->parser->convertOrderId($orderId)))) {
2682-
return $this->parser->parseCancelOrderResult($result);
2683-
}
2684-
} catch (SoapFault $e) {
2685-
$msg = $e->getMessage();
2686-
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
2687-
sleep(1);
2688-
return $this->cancelOrder($orderId, $attempts+1);
2689-
} else {
2690-
throw new MplusQAPIException('SoapFault occurred: '.$msg, 0, $e);
2691-
}
2692-
} catch (Exception $e) {
2693-
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
2678+
public function cancelOrder($orderId, $branchNumber = null, $attempts = 0) {
2679+
try {
2680+
if (false !== ($result = $this->client->cancelOrder($this->parser->convertCancelOrder($orderId, $branchNumber)))) {
2681+
return $this->parser->parseCancelOrderResult($result);
2682+
}
2683+
} catch (SoapFault $e) {
2684+
$msg = $e->getMessage();
2685+
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
2686+
sleep(1);
2687+
return $this->cancelOrder($orderId, $branchNumber, $attempts + 1);
2688+
} else {
2689+
throw new MplusQAPIException('SoapFault occurred: ' . $msg, 0, $e);
2690+
}
2691+
} catch (Exception $e) {
2692+
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
2693+
}
26942694
}
2695-
} // END cancelOrder()
2695+
// END cancelOrder()
26962696

26972697
//----------------------------------------------------------------------------
26982698

@@ -3549,6 +3549,22 @@ public function getAuthorizationTree($attempts = 0) {
35493549
}
35503550

35513551
// END getAuthorizationTree()
3552+
3553+
//----------------------------------------------------------------------------
3554+
public function updateOrderV2($order) {
3555+
try {
3556+
if (!isset($order['orderId'])) {
3557+
throw new MplusQAPIException('No orderId set.');
3558+
}
3559+
$result = $this->client->updateOrderV2($this->parser->convertUpdateOrderV2($order));
3560+
return $this->parser->parseUpdateOrderV2Result($result);
3561+
} catch (SoapFault $e) {
3562+
throw new MplusQAPIException('SoapFault occurred: ' . $e->getMessage(), 0, $e);
3563+
} catch (Exception $e) {
3564+
throw new MplusQAPIException('Exception occurred: ' . $e->getMessage(), 0, $e);
3565+
}
3566+
}
3567+
// END updateOrderV2()
35523568
}
35533569

35543570
//==============================================================================
@@ -6116,6 +6132,20 @@ public function parseGetAuthorizationTreeResult($soapGetAuthorizationTreeResult)
61166132
}
61176133
}
61186134
// END parseGetAuthorizationTreeResult()
6135+
6136+
//----------------------------------------------------------------------------
6137+
public function parseUpdateOrderV2Result($soapUpdateOrderV2Result) {
6138+
if (isset($soapUpdateOrderV2Result->result) and $soapUpdateOrderV2Result->result == 'UPDATE-ORDER-RESULT-OK') {
6139+
if (isset($soapUpdateOrderV2Result->order)) {
6140+
return $this->parseOrder($soapUpdateOrderV2Result->order);
6141+
} else {
6142+
return true;
6143+
}
6144+
} else {
6145+
return false;
6146+
}
6147+
}
6148+
// END parseUpdateOrderV2Result()
61196149

61206150
//----------------------------------------------------------------------------
61216151

@@ -8850,6 +8880,35 @@ public function convertUpdateGroupAuthorizationsRequest($groupNumber, $authoriza
88508880
}
88518881
// END convertUpdateGroupAuthorizationsRequest()
88528882

8883+
//----------------------------------------------------------------------------
8884+
public function convertCancelOrder($orderId, $branchNumber = null) {
8885+
$data = array('orderId' => $orderId);
8886+
if ($branchNumber !== null) {
8887+
$data['request'] = array('branchNumber' => $branchNumber);
8888+
}
8889+
$object = arrayToObject($data);
8890+
return $object;
8891+
}
8892+
// END convertCancelOrder()
8893+
8894+
//----------------------------------------------------------------------------
8895+
public function convertUpdateOrderV2($order, $applySalesAndActions = null, $applySalesPrices = null, $applyPriceGroups = null) {
8896+
$order = $this->convertOrder($order);
8897+
$request = ['order' => $order->order];
8898+
if (!is_null($applySalesAndActions)) {
8899+
$request['applySalesAndActions'] = $applySalesAndActions;
8900+
}
8901+
if (!is_null($applySalesPrices)) {
8902+
$request['applySalesPrices'] = $applySalesPrices;
8903+
}
8904+
if (!is_null($applyPriceGroups)) {
8905+
$request['applyPriceGroups'] = $applyPriceGroups;
8906+
}
8907+
$object = arrayToObject(['request' => $request]);
8908+
return $object;
8909+
}
8910+
// END convertUpdateOrderV2()
8911+
88538912
}
88548913

88558914
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)