The Lightspeed Retail API (irritatingly) returns results as a single array if count = 1, and a multi-dimensional array if count > 1. The following code normalises this in ApiClient.php:
// fix Lightspeed unstructured way of returning an array when a multi dimensional array is expected
if (isset($response['@attributes']['count']) && $response['@attributes']['count'] === 1) {
$response[$resource] = [$response[$resource]];
}
However, since v3.0 (?), the count attribute is not returned with a set of results, so this test does not work. Perhaps this?
// fix Lightspeed unstructured way of returning an array when a multi dimensional array is expected
if (!is_array($response[$resource][array_key_first($response[$resource])])) {
$response[$resource] = [$response[$resource]];
}
The Lightspeed Retail API (irritatingly) returns results as a single array if count = 1, and a multi-dimensional array if count > 1. The following code normalises this in ApiClient.php:
However, since v3.0 (?), the count attribute is not returned with a set of results, so this test does not work. Perhaps this?