Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(REST API): add url to (un)archive cards #6138

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
28 changes: 28 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions lib/Controller/CardApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/controller/CardApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down