diff --git a/appinfo/routes.php b/appinfo/routes.php index 0231397cb..b2562fb10 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -102,6 +102,8 @@ ['name' => 'card_api#assignUser', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/assignUser', 'verb' => 'PUT'], ['name' => 'card_api#unassignUser', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/unassignUser', 'verb' => 'PUT'], ['name' => 'card_api#reorder', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/reorder', 'verb' => 'PUT'], + ['name' => 'card_api#archive', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/archive', 'verb' => 'PUT'], + ['name' => 'card_api#unarchive', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/unarchive', 'verb' => 'PUT'], ['name' => 'card_api#delete', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}', 'verb' => 'DELETE'], ['name' => 'card_api#findAllWithDue', 'url' => '/api/v{apiVersion}/dashboard/due', 'verb' => 'GET'], diff --git a/docs/API.md b/docs/API.md index 9b9d338a2..eafab9e4a 100644 --- a/docs/API.md +++ b/docs/API.md @@ -347,6 +347,34 @@ A 403 response might be returned if the users ability to create new boards has b ##### 200 Success +### PUT /boards/{boardId}/stacks/{stackId}/cards/{cardId}/archive - Archive a card + +#### Request parameters + +| Parameter | Type | Description | +| --------- | ------- | --------------------------------------- | +| boardId | Integer | The id of the board the card belongs to | +| stackId | Integer | The id of the stack the card belongs to | +| cardId | Integer | The id of the card | + +#### Response + +##### 200 Success + +### PUT /boards/{boardId}/stacks/{stackId}/cards/{cardId}/unarchive - Unarchive a card + +#### Request parameters + +| Parameter | Type | Description | +| --------- | ------- | --------------------------------------- | +| boardId | Integer | The id of the board the card belongs to | +| stackId | Integer | The id of the stack the card belongs to | +| cardId | Integer | The id of the card | + +#### Response + +##### 200 Success + ### DELETE /boards/{boardId} - Delete a board #### Request parameters diff --git a/lib/Controller/CardApiController.php b/lib/Controller/CardApiController.php index 900c27475..a013b159a 100644 --- a/lib/Controller/CardApiController.php +++ b/lib/Controller/CardApiController.php @@ -152,6 +152,30 @@ public function unassignUser($cardId, $userId, $type = 0) { return new DataResponse($card, HTTP::STATUS_OK); } + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * Archive card + */ + public function archive($cardId) { + $card = $this->cardService->archive($cardId); + return new DataResponse($card, HTTP::STATUS_OK); + } + + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * Unarchive card + */ + public function unarchive($cardId) { + $card = $this->cardService->unarchive($cardId); + return new DataResponse($card, HTTP::STATUS_OK); + } + /** * @NoAdminRequired * @CORS diff --git a/tests/unit/controller/CardApiControllerTest.php b/tests/unit/controller/CardApiControllerTest.php index 9922906ff..35ee20cbb 100644 --- a/tests/unit/controller/CardApiControllerTest.php +++ b/tests/unit/controller/CardApiControllerTest.php @@ -119,6 +119,32 @@ public function testUpdate() { $this->assertEquals($expected, $actual); } + public function testArchive() { + $card = new Card(); + $card->setId($this->cardExample['id']); + + $this->cardService->expects($this->once()) + ->method('archive') + ->willReturn($card); + + $expected = new DataResponse($card, HTTP::STATUS_OK); + $actual = $this->controller->archive($this->cardExample['id']); + $this->assertEquals($expected, $actual); + } + + public function testUnArchive() { + $card = new Card(); + $card->setId($this->cardExample['id']); + + $this->cardService->expects($this->once()) + ->method('unarchive') + ->willReturn($card); + + $expected = new DataResponse($card, HTTP::STATUS_OK); + $actual = $this->controller->unarchive($this->cardExample['id']); + $this->assertEquals($expected, $actual); + } + public function testDelete() { $card = new Card(); $card->setId($this->cardExample['id']);