added subscription rest api controller and route
This commit is contained in:
parent
5e24706796
commit
b28e0619f5
2 changed files with 44 additions and 0 deletions
|
@ -7,5 +7,6 @@ return [
|
|||
'resources' => [
|
||||
],
|
||||
'routes' => [
|
||||
['name' => 'subscription#destroy', 'url' => '/subscriptions/{id}', 'verb' => 'DELETE']
|
||||
]
|
||||
];
|
43
lib/Controller/SubscriptionController.php
Normal file
43
lib/Controller/SubscriptionController.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\DavPush\Controller;
|
||||
|
||||
use OCA\DavPush\AppInfo\Application;
|
||||
use OCA\DavPush\Service\SubscriptionService;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\IRequest;
|
||||
|
||||
class SubscriptionController extends Controller {
|
||||
/** @var SubscriptionService */
|
||||
private $service;
|
||||
|
||||
/** @var string */
|
||||
private $userId;
|
||||
|
||||
use Errors;
|
||||
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
SubscriptionService $service,
|
||||
$userId
|
||||
) {
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
$this->service = $service;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
#[NoAdminRequired]
|
||||
#[NoCSRFRequired]
|
||||
public function destroy(int $id): JSONResponse {
|
||||
return $this->handleNotFound(function () use ($id) {
|
||||
$this->service->delete($this->userId, $id);
|
||||
return [
|
||||
'success' => True,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue