Fix the routing and the stacks API endpoint.
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
a4b348488b
commit
40f34eb3bc
@@ -83,7 +83,7 @@ return [
|
|||||||
['name' => 'board_api#delete', 'url' => '/api/v1.0/board/{id}', 'verb' => 'DELETE'],
|
['name' => 'board_api#delete', 'url' => '/api/v1.0/board/{id}', 'verb' => 'DELETE'],
|
||||||
['name' => 'board_api#undo_delete', 'url' => '/api/v1.0/board/{id}/undo_delete', 'verb' => 'POST'],
|
['name' => 'board_api#undo_delete', 'url' => '/api/v1.0/board/{id}/undo_delete', 'verb' => 'POST'],
|
||||||
|
|
||||||
['name' => 'stack_api#index', 'url' => '/api/v1.0/boards/{boardId}/stacks', 'verb' => 'GET'],
|
['name' => 'stack_api#index', 'url' => '/api/v1.0/board/{boardId}/stacks', 'verb' => 'GET'],
|
||||||
['name' => 'stack_api#create', 'url' => '/api/v1.0/board/{boardId}/stack', 'verb' => 'POST'],
|
['name' => 'stack_api#create', 'url' => '/api/v1.0/board/{boardId}/stack', 'verb' => 'POST'],
|
||||||
['name' => 'stack_api#delete', 'url' => '/api/v1.0/board/{boardId}/stack/{id}', 'verb' => 'DELETE'],
|
['name' => 'stack_api#delete', 'url' => '/api/v1.0/board/{boardId}/stack/{id}', 'verb' => 'DELETE'],
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ namespace OCA\Deck\Controller;
|
|||||||
use OCP\AppFramework\ApiController;
|
use OCP\AppFramework\ApiController;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUserManager;
|
|
||||||
use OCP\IGroupManager;
|
|
||||||
|
|
||||||
use OCA\Deck\Service\StackService;
|
use OCA\Deck\Service\StackService;
|
||||||
|
|
||||||
@@ -45,12 +43,10 @@ class StackApiController extends ApiController {
|
|||||||
* @param string $appName
|
* @param string $appName
|
||||||
* @param IRequest $request
|
* @param IRequest $request
|
||||||
* @param StackService $service
|
* @param StackService $service
|
||||||
* @param $boardId
|
|
||||||
*/
|
*/
|
||||||
public function __construct($appName, IRequest $request, StackService $service, $boardId) {
|
public function __construct($appName, IRequest $request, StackService $service) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->service = $service;
|
$this->service = $service;
|
||||||
$this->boardId = $boardId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,8 +56,8 @@ class StackApiController extends ApiController {
|
|||||||
*
|
*
|
||||||
* Return all of the stacks in the specified board.
|
* Return all of the stacks in the specified board.
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index($boardId) {
|
||||||
$stacks = $this->service->findAll($this->boardId);
|
$stacks = $this->service->findAll($boardId);
|
||||||
|
|
||||||
return new DataResponse($stacks);
|
return new DataResponse($stacks);
|
||||||
}
|
}
|
||||||
@@ -76,9 +72,9 @@ class StackApiController extends ApiController {
|
|||||||
*
|
*
|
||||||
* Create a stack with the specified title and order.
|
* Create a stack with the specified title and order.
|
||||||
*/
|
*/
|
||||||
public function create($title, $order) {
|
public function create($boardId, $title, $order) {
|
||||||
// this throws a StatusException that needs to be caught and handled
|
// this throws a StatusException that needs to be caught and handled
|
||||||
$stack = $this->service->create($title, $this->boardId, $order);
|
$stack = $this->service->create($title, $boardId, $order);
|
||||||
|
|
||||||
return new DataResponse($stack);
|
return new DataResponse($stack);
|
||||||
}
|
}
|
||||||
@@ -92,7 +88,7 @@ class StackApiController extends ApiController {
|
|||||||
*
|
*
|
||||||
* Delete the stack specified by $id. Return the board that was deleted.
|
* Delete the stack specified by $id. Return the board that was deleted.
|
||||||
*/
|
*/
|
||||||
public function delete($id) {
|
public function delete($boardId, $id) {
|
||||||
$stack = $this->service->delete($id);
|
$stack = $this->service->delete($id);
|
||||||
|
|
||||||
return new DataResponse($stack);
|
return new DataResponse($stack);
|
||||||
|
|||||||
Reference in New Issue
Block a user