getSquareItems not filtering types
Closed this issue · 1 comments
BarnumD commented
In the following example, listCatalog
is not filtering by types, such as ITEM.'
function getSquareCatalog($types = 'ITEM'){
$client = getApiClient();
$catalogApi = $client->getCatalogApi();
$cursor = 'initial';
$catalog = array();
while ($cursor){
if ($cursor == 'initial'){$cursor = null;}
$apiResponse = $catalogApi->listCatalog($cursor, $types);
if ($apiResponse->isSuccess()) {
$listCatalogResponse = $apiResponse->getResult();
$catalog= array_merge ($catalog, $listCatalogResponse->getObjects());
$cursor = $listCatalogResponse->getCursor();
}
}
return $catalog;
}
print("<pre>".print_r(getSquareCatalog(),true)."</pre>");
Returns all item types including ITEM, CATEGORY, TAX, DISCOUNT
BarnumD commented
User issue, failed to realize I was calling getSquareCatalog() with null argument.