rename parameter for read/unread api call

Signed-off-by: Paul Tirk <paultirk@paultirk.com>
This commit is contained in:
Paul Tirk 2022-04-13 15:14:48 +02:00 committed by Benjamin Brahmer
parent 3bdafbfcea
commit da5e749ecc
4 changed files with 44 additions and 10 deletions

View File

@ -97,8 +97,8 @@ return ['routes' => [
['name' => 'item_api#read', 'url' => '/api/v1-3/items/{itemId}/read', 'verb' => 'POST'],
['name' => 'item_api#unread', 'url' => '/api/v1-3/items/{itemId}/unread', 'verb' => 'POST'],
['name' => 'item_api#read_all', 'url' => '/api/v1-3/items/read', 'verb' => 'POST'],
['name' => 'item_api#read_multiple', 'url' => '/api/v1-3/items/read/multiple', 'verb' => 'POST'],
['name' => 'item_api#unread_multiple', 'url' => '/api/v1-3/items/unread/multiple', 'verb' => 'POST'],
['name' => 'item_api#read_multiple_by_ids', 'url' => '/api/v1-3/items/read/multiple', 'verb' => 'POST'],
['name' => 'item_api#unread_multiple_by_ids', 'url' => '/api/v1-3/items/unread/multiple', 'verb' => 'POST'],
['name' => 'item_api#star_by_item_id', 'url' => '/api/v1-3/items/{itemId}/star', 'verb' => 'POST'],
['name' => 'item_api#unstar_by_item_id', 'url' => '/api/v1-3/items/{itemId}/unstar', 'verb' => 'POST'],
['name' => 'item_api#star_multiple_by_item_ids', 'url' => '/api/v1-3/items/star/multiple', 'verb' => 'POST'],

View File

@ -530,7 +530,7 @@ This is used to stay up to date.
* **Parameters**:
```jsonc
{
"items": [2, 3] // ids of the items
"itemIds": [2, 3] // ids of the items
}
```
* **Returns**: nothing
@ -551,7 +551,7 @@ This is used to stay up to date.
* **Parameters**:
```jsonc
{
"items": [2, 3] // ids of the items
"itemIds": [2, 3] // ids of the items
}
```
* **Returns**: nothing

View File

@ -323,14 +323,14 @@ class ItemApiController extends ApiController
}
/**
* @param array $items
* @param array $itemIds
* @param bool $isRead
*
* @throws ServiceConflictException
*/
private function setMultipleRead(array $items, bool $isRead): void
private function setMultipleRead(array $itemIds, bool $isRead): void
{
foreach ($items as $id) {
foreach ($itemIds as $id) {
try {
$this->itemService->read($this->getUserId(), $id, $isRead);
} catch (ServiceNotFoundException $ex) {
@ -359,6 +359,23 @@ class ItemApiController extends ApiController
}
/**
* @NoAdminRequired
* @NoCSRFRequired
* @CORS
*
* @param int[] $itemIds item ids
*
* @return void
*
* @throws ServiceConflictException
*/
public function readMultipleByIds(array $itemIds): void
{
$this->setMultipleRead($itemIds, true);
}
/**
* @NoAdminRequired
*
@ -378,6 +395,23 @@ class ItemApiController extends ApiController
}
/**
* @NoAdminRequired
* @NoCSRFRequired
* @CORS
*
* @param int[] $itemIds item ids
*
* @return void
*
* @throws ServiceConflictException
*/
public function unreadMultipleByIds(array $itemIds): void
{
$this->setMultipleRead($itemIds, false);
}
/**
* @param array $items
* @param bool $isStarred

View File

@ -398,7 +398,7 @@ class ItemApiControllerTest extends TestCase
[$this->user->getUID(), 2, true],
[$this->user->getUID(), 4, true]
);
$this->class->readMultiple([2, 4]);
$this->class->readMultipleByIds([2, 4]);
}
@ -411,7 +411,7 @@ class ItemApiControllerTest extends TestCase
[$this->user->getUID(), 4, true]
)
->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), new Item());
$this->class->readMultiple([2, 4]);
$this->class->readMultipleByIds([2, 4]);
}
@ -423,7 +423,7 @@ class ItemApiControllerTest extends TestCase
[$this->user->getUID(), 2, false],
[$this->user->getUID(), 4, false]
);
$this->class->unreadMultiple([2, 4]);
$this->class->unreadMultipleByIds([2, 4]);
}