Skip to content

Commit

Permalink
Added api calls :
Browse files Browse the repository at this point in the history
-getProductOverview
-getProductOverviewFields
  • Loading branch information
Dennis van den Heerik committed Oct 18, 2019
1 parent ae65736 commit addd2f8
Showing 1 changed file with 109 additions and 1 deletion.
110 changes: 109 additions & 1 deletion Mplusqapiclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MplusQAPIclient
{
const CLIENT_VERSION = '1.25.1';
const CLIENT_VERSION = '1.26.0';
const WSDL_TTL = 300; // 5 min WSDL TTL

var $MIN_API_VERSION_MAJOR = 0;
Expand Down Expand Up @@ -3301,6 +3301,46 @@ public function getSalePromotions($branchNumbers = [], $attempts=0)
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
}
} // END getSalePromotions()

//----------------------------------------------------------------------------
public function getProductOverview($selectFields, $pageNumber = null, $maxPerPage = null, $orderField = null, $sortOrder = null, $filters = null, $search=null, $attempts=0)
{
try {
$request = $this->parser->convertGetProductOverviewRequest($selectFields, $pageNumber, $maxPerPage, $orderField, $sortOrder, $filters, $search);
$result = $this->client->getProductOverview($request);
return $this->parser->parseGetProductOverviewResult($result);
} catch (SoapFault $e) {
$msg = $e->getMessage();
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
sleep(1);
return $this->getProductOverview($selectFields, $pageNumber, $maxPerPage, $orderField, $sortOrder, $filters, $search, $attempts+1);
} else {
throw new MplusQAPIException('SoapFault occurred: '.$msg, 0, $e);
}
} catch (Exception $e) {
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
}
} // END getProductOverview()

//----------------------------------------------------------------------------
public function getProductOverviewFields($attempts=0)
{
try {
$request = $this->parser->convertGetProductOverviewFieldsRequest();
$result = $this->client->getProductOverviewFields($request);
return $this->parser->parseGetProductOverviewFieldsResult($result);
} catch (SoapFault $e) {
$msg = $e->getMessage();
if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) {
sleep(1);
return $this->getProductOverviewFields($attempts+1);
} else {
throw new MplusQAPIException('SoapFault occurred: '.$msg, 0, $e);
}
} catch (Exception $e) {
throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e);
}
} // END getProductOverview()

}

Expand Down Expand Up @@ -5749,6 +5789,32 @@ public function parseGetSalePromotionsResult($soapGetSalePromotionsResult) {
return $salePromotions;
} // END parseGetSalePromotionsResult()

//----------------------------------------------------------------------------
public function parseGetProductOverviewResult($soapGetProductOverviewResult) {
$productOverview = array();
if(isset($soapGetProductOverviewResult->productOverview)) {
$productOverview = objectToArray($soapGetProductOverviewResult->productOverview);
}
if (isset($soapGetProductOverviewResult->productOverviewArticleList->productOverviewArticle)) {
$productOverview['productOverviewArticleList'] = objectToArray($soapGetProductOverviewResult->productOverviewArticleList->productOverviewArticle);
}
return $productOverview;
} // END parseGetProductOverviewResult()

//----------------------------------------------------------------------------
public function parseGetProductOverviewFieldsResult($soapGetProductOverviewFieldsResult) {
$productOverviewFields = array();
die(print_r($soapGetProductOverviewFieldsResult, true));

if(isset($soapGetProductOverviewResult->productOverview)) {
$productOverview = objectToArray($soapGetProductOverviewResult->productOverview);
}
if (isset($soapGetProductOverviewResult->productOverviewArticleList->productOverviewArticle)) {
$productOverview['productOverviewArticleList'] = objectToArray($soapGetProductOverviewResult->productOverviewArticleList->productOverviewArticle);
}
return $productOverview;
} // END parseGetProductOverviewFieldsResult()


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

Expand Down Expand Up @@ -8027,6 +8093,48 @@ public function convertGetSalePromotionsRequest($branchNumbers)
$object = arrayToObject($array);
return $object;
} // END convertGetSalePromotionsRequest()

//----------------------------------------------------------------------------
public function convertGetProductOverviewRequest($selectFieldList, $pageNumber, $maxPerPage, $orderField, $sortOrder, $filters, $search)
{
$request = new stdClass();
$request->request = new stdClass();

if(!is_array($selectFieldList)) {
$selectFieldList = array($selectFieldList);
}
$request->request->selectFieldNameList = $selectFieldList;

if(isset($pageNumber)) {
$request->request->pageNumber = $pageNumber;
}
if(isset($maxPerPage)) {
$request->request->maxPerPage = $maxPerPage;
}
if(isset($orderField)) {
$request->request->orderField = $orderField;
}
if(isset($sortOrder)) {
$request->request->sortOrder = $sortOrder;
}

if(isset($filters)) {
$request->request->filterList = $filters;
}

if(isset($search)) {
$request->request->search = $search;
}
return $request;
} // END convertGetProductOverviewRequest()

//----------------------------------------------------------------------------
public function convertGetProductOverviewFieldsRequest()
{
$request = new stdClass();
$request->request = new stdClass();
return $request;
} // END convertGetProductOverviewFieldsRequest()

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

Expand Down

0 comments on commit addd2f8

Please sign in to comment.