Skip to content

Commit

Permalink
Merge branch 'getKitchenTickets' into 'master'
Browse files Browse the repository at this point in the history
getKitchenTickets added

See merge request mpluskassa/mplus-api-client!37
  • Loading branch information
freerk-mpluskassa committed May 6, 2020
2 parents 9a11a23 + 844036e commit b297e2c
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Mplusqapiclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,29 @@ public function getTableListV3($request, $attempts=0)

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

public function getKitchenTickets($request=null, $attempts=0)
{
try {
$result = $this->client->getKitchenTickets($this->parser->convertGetKitchenTicketsRequest($request));
if ($this->returnRawResult) {
return $result;
}
return $this->parser->parseGetKitchenTickets($result);
} catch (SoapFault $e) {
$msg = $e->getMessage();
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
sleep(1);
return $this->getKitchenTickets($request, $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 getCurrentTableOrders($request=null, $attempts=0)
{
try {
Expand Down Expand Up @@ -5416,6 +5439,29 @@ public function parseGetInvoicesResult($soapInvoicesResult) {

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

public function parseGetKitchenTickets($soapResult)
{
$kitchenTickets = [];
if (isset($soapResult->kitchenTicketList->kitchenTicket)) {
$kitchenTickets = objectToArray($soapResult->kitchenTicketList->kitchenTicket);
foreach ($kitchenTickets as $kitchenTicketIdx => $kitchenTicket) {
if (isset($kitchenTicket['kitchenTicketCourseList']['kitchenTicketCourse'])) {
$kitchenTicket['kitchenTicketCourseList'] = $kitchenTicket['kitchenTicketCourseList']['kitchenTicketCourse'];
}
foreach ($kitchenTicket['kitchenTicketCourseList'] as $kitchenTicketCourseIdx => $kitchenTicketCourse) {
if (isset($kitchenTicketCourse['kitchenTicketLineList']['kitchenTicketLine'])) {
$kitchenTicketCourse['kitchenTicketLineList'] = $kitchenTicketCourse['kitchenTicketLineList']['kitchenTicketLine'];
}
$kitchenTicket['kitchenTicketCourseList'][$kitchenTicketCourseIdx] = $kitchenTicketCourse;
}
$kitchenTickets[$kitchenTicketIdx] = $kitchenTicket;
}
}
return $kitchenTickets;
}

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

public function parseGetOrdersResult($soapOrdersResult)
{
$orders = array();
Expand Down Expand Up @@ -8581,6 +8627,17 @@ public function convertGetTableListV3Request($request)

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

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

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

public function convertGetCurrentTableOrdersRequest($request)
{
if (is_null($request)) {
Expand Down

0 comments on commit b297e2c

Please sign in to comment.