mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Removde the /objects/{entity}/search API endpoint, added the new filter capabilities to /objects/{entity} (references #985)
This commit is contained in:
parent
16b17b25a4
commit
62997d39bc
@ -132,11 +132,13 @@ _- (Because the stock quantity unit is now the base for everything, it cannot be
|
||||
- All prices are now related to the products stock quantity unit (instead of the products purchase QU)
|
||||
- All (product) amounts are now related to the products stock quantity unit (was related to the products purchase QU for the shopping list before)
|
||||
- The product object no longer has a field `barcodes` with a comma separated barcode list, instead barcodes are now stored in a separate table/entity `product_barcodes` (use the existing "Generic entity interactions" endpoints to access them)
|
||||
- The endpoint `/objects/{entity}/search` was removed (use the existing `/objects/{entity}` endpoint with new new filter capabilities mentioned below)
|
||||
- The output / field names of `ProductDetailsResponse` have slightly changed (endpoint `/stock/products/{productId}`)
|
||||
- For better integration (apps), it's now possible to show a QR-Code for API keys (thanks @fipwmaqzufheoxq92ebc)
|
||||
- New QR-Code button on the "Manage API keys"-page (top right corner settings menu), the QR-Codes contains `<API-Url>|<API-Key>`
|
||||
- And on the calendar page when using the button "Share/Integrate calendar (iCal)", there the QR-Codes contains the Share-URL (which is displayed in the textbox above)
|
||||
- The output of the following endpoints can now be filtered (by any field), ordered and paginated (thanks @fipwmaqzufheoxq92ebc)
|
||||
- `/objects/{entity}/search`
|
||||
- The output of the following endpoints can now be filtered (by any field), ordered and paginated (thanks for the initial work on this @fipwmaqzufheoxq92ebc)
|
||||
- `/objects/{entity}`
|
||||
- `/stock/products/{productId}/entries`
|
||||
- `/stock/products/{productId}/locations`
|
||||
- `/recipes/fulfillment`
|
||||
|
@ -135,7 +135,7 @@ class GenericEntityApiController extends BaseApiController
|
||||
|
||||
public function GetObjects(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$objects = $this->getDatabase()->{$args['entity']}();
|
||||
$objects = $this->queryData($this->getDatabase()->{$args['entity']}(), $request->getQueryParams());
|
||||
$allUserfields = $this->getUserfieldsService()->GetAllValues($args['entity']);
|
||||
|
||||
foreach ($objects as $object)
|
||||
@ -176,25 +176,6 @@ class GenericEntityApiController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
public function SearchObjects(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->FilteredApiResponse($response, $this->getDatabase()->{$args['entity']}(), $request->getQueryParams());
|
||||
}
|
||||
catch (\PDOException $ex)
|
||||
{
|
||||
throw new HttpBadRequestException($request, $ex->getMessage(), $ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
|
||||
}
|
||||
}
|
||||
|
||||
public function SetUserfields(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
|
||||
|
@ -524,81 +524,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/objects/{entity}/search/{searchString}": {
|
||||
"get": {
|
||||
"summary": "Returns all objects of the given entity where the field \"name\" contains the search string (so only works for entities which have that field)",
|
||||
"tags": [
|
||||
"Generic entity interactions"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "entity",
|
||||
"required": true,
|
||||
"description": "A valid entity name",
|
||||
"schema": {
|
||||
"$ref": "#/components/internalSchemas/ExposedEntity"
|
||||
}
|
||||
},
|
||||
{
|
||||
"in": "path",
|
||||
"name": "searchString",
|
||||
"required": true,
|
||||
"description": "The search string",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "An entity object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/Product"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/Chore"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/Battery"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/Location"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/QuantityUnit"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/ShoppingListItem"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/StockEntry"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "The operation was not successful",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/GenericErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/userfields/{entity}/{objectId}": {
|
||||
"get": {
|
||||
"summary": "Returns all userfields with their values of the given object of the given entity",
|
||||
|
@ -271,7 +271,7 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
|
||||
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
||||
{
|
||||
Grocy.Api.Get('objects/product_barcodes/search/?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
function(barcodeResult)
|
||||
{
|
||||
if (barcodeResult != null)
|
||||
|
@ -150,7 +150,6 @@ $app->group('/api', function (RouteCollectorProxy $group) {
|
||||
// Generic entity interaction
|
||||
$group->get('/objects/{entity}', '\Grocy\Controllers\GenericEntityApiController:GetObjects');
|
||||
$group->get('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:GetObject');
|
||||
$group->get('/objects/{entity}/search/{searchString:.*}', '\Grocy\Controllers\GenericEntityApiController:SearchObjects');
|
||||
$group->post('/objects/{entity}', '\Grocy\Controllers\GenericEntityApiController:AddObject');
|
||||
$group->put('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:EditObject');
|
||||
$group->delete('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:DeleteObject');
|
||||
|
Loading…
x
Reference in New Issue
Block a user