Merge pull request #6138 from xyjonas/programmatic-archive-unarchive-card
Feat(REST API): add url to (un)archive cards
This commit is contained in:
@@ -103,6 +103,8 @@ return [
|
||||
['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'],
|
||||
|
||||
28
docs/API.md
28
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
|
||||
|
||||
@@ -153,6 +153,30 @@ class CardApiController extends ApiController {
|
||||
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
|
||||
|
||||
@@ -120,6 +120,32 @@ class CardApiControllerTest extends \Test\TestCase {
|
||||
$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']);
|
||||
|
||||
Reference in New Issue
Block a user