From 62996d91056b6da238d7c7cb0ef2e0c997c4159c Mon Sep 17 00:00:00 2001 From: Paul Tirk Date: Tue, 4 May 2021 18:37:57 +0200 Subject: [PATCH] add routes for v2 feed api Signed-off-by: Paul Tirk --- appinfo/routes.php | 4 + lib/Controller/FeedApiV2Controller.php | 108 +++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 lib/Controller/FeedApiV2Controller.php diff --git a/appinfo/routes.php b/appinfo/routes.php index 09348bc7b6..0778fc8206 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -66,6 +66,10 @@ ['name' => 'folder_api_v2#update', 'url' => '/api/v2/folders/{folderId}', 'verb' => 'PATCH'], ['name' => 'folder_api_v2#delete', 'url' => '/api/v2/folders/{folderId}', 'verb' => 'DELETE'], +['name' => 'feed_api_v2#create', 'url' => '/api/v2/feeds', 'verb' => 'POST'], +['name' => 'feed_api_v2#update', 'url' => '/api/v2/feeds/{feedId}', 'verb' => 'PATCH'], +['name' => 'feed_api_v2#delete', 'url' => '/api/v2/feeds/{feedId}', 'verb' => 'DELETE'], + // API 1.2 ['name' => 'utility_api#version', 'url' => '/api/v1-2/version', 'verb' => 'GET'], ['name' => 'utility_api#status', 'url' => '/api/v1-2/status', 'verb' => 'GET'], diff --git a/lib/Controller/FeedApiV2Controller.php b/lib/Controller/FeedApiV2Controller.php new file mode 100644 index 0000000000..9e19a6e2c9 --- /dev/null +++ b/lib/Controller/FeedApiV2Controller.php @@ -0,0 +1,108 @@ + + * @copyright 2020 Paul Tirk + */ + +namespace OCA\News\Controller; + +use OCA\News\Db\Feed; +use \Psr\Log\LoggerInterface; + +use \OCP\IRequest; +use \OCP\IUserSession; +use \OCP\AppFramework\Http; + +use \OCA\News\Service\FeedServiceV2; +use \OCA\News\Service\ItemServiceV2; +use \OCA\News\Service\Exceptions\ServiceNotFoundException; +use \OCA\News\Service\Exceptions\ServiceConflictException; + +class FeedApiV2Controller extends ApiController +{ + use ApiPayloadTrait; + use JSONHttpErrorTrait; + + private $itemService; + private $feedService; + private $loggerInterface; + + public function __construct( + IRequest $request, + IUserSession $userSession, + FeedServiceV2 $feedService, + ItemServiceV2 $itemService, + LoggerInterface $loggerInterface + ) { + parent::__construct($request, $userSession); + $this->feedService = $feedService; + $this->itemService = $itemService; + + $this->loggerInterface = $loggerInterface; + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * @CORS + * + * @param string $url + * @param string $name + * @param int $ordering + * @param int $folderId + * @param bool $isPinned + * @param bool $fullTextEnabled + * @param string $basicAuthUser + * @param string $basicAuthPassword + * @return array|mixed|\OCP\AppFramework\Http\JSONResponse + */ + public function create( + string $url, + string $name = '', + int $ordering = 0, + int $folderId = null, + bool $isPinned = false, + bool $fullTextEnabled = false, + string $basicAuthUser = null, + string $basicAuthPassword = null + ) { + } + + /** + * @NoCSRFRequired + * + * @param Entity $userId + * @param int $feedId + */ + public function update( + int $feedId, + string $url = '', + string $name = '', + int $ordering = 0, + int $folderId = null, + bool $isPinned = false, + bool $fullTextEnabled = false, + string $basicAuthUser = null, + string $basicAuthPassword = null + ) { + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * @CORS + * + * @param int $feedId + * @return array|\OCP\AppFramework\Http\JSONResponse + */ + public function delete(int $feedId) + { + } + +} +