-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UserConfiguration Controller and moved methods
- Loading branch information
Showing
3 changed files
with
103 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
declare(strict_types=1); | ||
// SPDX-FileCopyrightText: Sebastian Krupinski <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\Data\Controller; | ||
|
||
use OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\IRequest; | ||
|
||
use OCA\Data\AppInfo\Application; | ||
use OCA\Data\Service\DataService; | ||
|
||
class UserConfigurationController extends Controller { | ||
private DataService $DataService; | ||
|
||
use Errors; | ||
|
||
public function __construct(IRequest $request, | ||
DataService $DataService, | ||
string $userId) { | ||
parent::__construct(Application::APP_ID, $request); | ||
$this->DataService = $DataService; | ||
$this->userId = $userId; | ||
} | ||
|
||
/** | ||
* handels collections list requests | ||
* | ||
* @NoAdminRequired | ||
* | ||
* @return DataResponse | ||
*/ | ||
public function listCollections(string $type): DataResponse { | ||
|
||
// evaluate if user id is present | ||
if ($this->userId === null) { | ||
return new DataResponse([], Http::STATUS_BAD_REQUEST); | ||
} | ||
// retrieve collections | ||
$rs = $this->DataService->listCollections($this->userId, $type); | ||
// return response | ||
if (isset($rs)) { | ||
return new DataResponse($rs); | ||
} else { | ||
return new DataResponse($rs['error'], 401); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* handels formats list requests | ||
* | ||
* @NoAdminRequired | ||
* | ||
* @return DataResponse | ||
*/ | ||
public function listFormats(string $type): DataResponse { | ||
|
||
// evaluate if user id is present | ||
if ($this->userId === null) { | ||
return new DataResponse([], Http::STATUS_BAD_REQUEST); | ||
} | ||
// retrieve formats | ||
$rs = $this->DataService->listFormats($type); | ||
// return response | ||
if (isset($rs)) { | ||
return new DataResponse($rs); | ||
} else { | ||
return new DataResponse($rs['error'], 401); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* handels services list requests | ||
* | ||
* @NoAdminRequired | ||
* | ||
* @return DataResponse | ||
*/ | ||
public function listServices(): DataResponse { | ||
|
||
// evaluate if user id is present | ||
if ($this->userId === null) { | ||
return new DataResponse([], Http::STATUS_BAD_REQUEST); | ||
} | ||
// retrieve formats | ||
$rs = $this->DataService->listServices($this->userId); | ||
// return response | ||
if (isset($rs)) { | ||
return new DataResponse($rs); | ||
} else { | ||
return new DataResponse($rs['error'], 401); | ||
} | ||
|
||
} | ||
} |