From b28e0619f50d48d72db403e97d09ead04531f50a Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Wed, 12 Jun 2024 14:21:35 +0200 Subject: [PATCH] added subscription rest api controller and route --- appinfo/routes.php | 1 + lib/Controller/SubscriptionController.php | 43 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 lib/Controller/SubscriptionController.php diff --git a/appinfo/routes.php b/appinfo/routes.php index b9eca4d..386e253 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -7,5 +7,6 @@ return [ 'resources' => [ ], 'routes' => [ + ['name' => 'subscription#destroy', 'url' => '/subscriptions/{id}', 'verb' => 'DELETE'] ] ]; \ No newline at end of file diff --git a/lib/Controller/SubscriptionController.php b/lib/Controller/SubscriptionController.php new file mode 100644 index 0000000..6a7798d --- /dev/null +++ b/lib/Controller/SubscriptionController.php @@ -0,0 +1,43 @@ +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, + ]; + }); + } +} \ No newline at end of file