diff options
author | Paul Tirk <paultirk@paultirk.com> | 2021-01-09 19:05:40 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 10:23:11 +0200 |
commit | 0d7d3cdfb4af9e5f369e229a0eb05d506f801da2 (patch) | |
tree | eddb5f6e2c73598d64701aafab85b75edf54a857 /lib/Controller/FolderApiV2Controller.php | |
parent | dff855fba5ce7e43d0ae4b68fd53eeab43dc7b5e (diff) |
move v2 api responses into existing php traits
Signed-off-by: Paul Tirk <paultirk@paultirk.com>
Diffstat (limited to 'lib/Controller/FolderApiV2Controller.php')
-rw-r--r-- | lib/Controller/FolderApiV2Controller.php | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/Controller/FolderApiV2Controller.php b/lib/Controller/FolderApiV2Controller.php index 683169006..b4ba8fcda 100644 --- a/lib/Controller/FolderApiV2Controller.php +++ b/lib/Controller/FolderApiV2Controller.php @@ -23,7 +23,8 @@ use \OCA\News\Service\Exceptions\ServiceValidationException; class FolderApiV2Controller extends ApiController { - use ApiV2ResponseTrait; + use ApiPayloadTrait; + use JSONHttpErrorTrait; private $folderService; private $itemService; @@ -52,16 +53,16 @@ class FolderApiV2Controller extends ApiController { try { $this->folderService->purgeDeleted($this->getUserId(), false); - $responseData = $this->serializeEntity( + $responseData = $this->serializeEntityV2( $this->folderService->create($this->getUserId(), $name) ); - return $this->response([ + return $this->responseV2([ 'folder' => $responseData ]); } catch (ServiceValidationException $ex) { - return $this->errorResponse($ex, Http::STATUS_BAD_REQUEST); + return $this->errorResponseV2($ex, Http::STATUS_BAD_REQUEST); } catch (ServiceConflictException $ex) { - return $this->errorResponse($ex, Http::STATUS_CONFLICT); + return $this->errorResponseV2($ex, Http::STATUS_CONFLICT); } } @@ -79,14 +80,14 @@ class FolderApiV2Controller extends ApiController try { $response = $this->folderService->rename($this->getUserId(), $folderId, $name); } catch (ServiceValidationException $ex) { - return $this->errorResponse($ex, Http::STATUS_UNPROCESSABLE_ENTITY); + return $this->errorResponseV2($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } catch (ServiceConflictException $ex) { - return $this->errorResponse($ex, Http::STATUS_CONFLICT); + return $this->errorResponseV2($ex, Http::STATUS_CONFLICT); } catch (ServiceNotFoundException $ex) { - return $this->errorResponse($ex, Http::STATUS_NOT_FOUND); + return $this->errorResponseV2($ex, Http::STATUS_NOT_FOUND); } - return $this->response([ + return $this->responseV2([ 'folder' => $response ]); } @@ -103,14 +104,14 @@ class FolderApiV2Controller extends ApiController public function delete($folderId) { try { - $responseData = $this->serializeEntity( + $responseData = $this->serializeEntityV2( $this->folderService->delete($this->getUserId(), $folderId) ); - return $this->response([ + return $this->responseV2([ 'folder' => $responseData ]); } catch (ServiceNotFoundException $ex) { - return $this->errorResponse($ex, Http::STATUS_NOT_FOUND); + return $this->errorResponseV2($ex, Http::STATUS_NOT_FOUND); } } } |