Optionally remove only done shopping list items (/stock/shoppinglist/clear API endpoint, closes #1730)

This commit is contained in:
Bernd Bestel
2022-01-06 14:07:29 +01:00
parent 0b36d02aa1
commit 3a6f04f770
4 changed files with 23 additions and 5 deletions

View File

@@ -233,13 +233,18 @@ class StockApiController extends BaseApiController
$requestBody = $this->GetParsedAndFilteredRequestBody($request);
$listId = 1;
if (array_key_exists('list_id', $requestBody) && !empty($requestBody['list_id']) && is_numeric($requestBody['list_id']))
{
$listId = intval($requestBody['list_id']);
}
$this->getStockService()->ClearShoppingList($listId);
$doneOnly = false;
if (array_key_exists('done_only', $requestBody) && filter_var($requestBody['done_only'], FILTER_VALIDATE_BOOLEAN) !== false)
{
$doneOnly = boolval($requestBody['done_only']);
}
$this->getStockService()->ClearShoppingList($listId, $doneOnly);
return $this->EmptyApiResponse($response);
}
catch (\Exception $ex)