From 6684730dd7f9ee62d0ecf12246c4bc4716a2bbd0 Mon Sep 17 00:00:00 2001 From: chandi Langecker Date: Mon, 26 Sep 2022 16:20:06 +0200 Subject: [PATCH] docs: sessions API documentation Signed-off-by: chandi Langecker --- docs/API.md | 75 ++++++++++++++++++++++++++++ lib/Controller/SessionController.php | 2 +- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/docs/API.md b/docs/API.md index 654f78b87..28a6b62ca 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1049,6 +1049,81 @@ Make a request to see the json schema of system ##### 200 Success +## Sessions + +### PUT /sessions/create - creates a new session + +#### Request body + +| Parameter | Type | Description | +| --------- | ------- | ---------------------------------------------------- | +| boardId | Integer | The id of the opened board | + +```json +{ + "boardId": 123 +} +``` + + +#### Response + +##### 200 Success + +```json +{ + "token":"LCGVgzFZBTMXPfcSVuWmrqLR0j8ZG5o1PpVLeHgTHZ5+4jOJNxlzUZ6ZfPbTTpqB" +} +``` + + +### POST /sessions/sync - notifies the server, that the session is still open + +#### Request body + +| Parameter | Type | Description | +| --------- | ------- | ---------------------------------------------------- | +| boardId | Integer | The id of the opened board | +| token | String | The session token from the /sessions/create response | + +```json +{ + "boardId": 123, + "token":"LCGVgzFZBTMXPfcSVuWmrqLR0j8ZG5o1PpVLeHgTHZ5+4jOJNxlzUZ6ZfPbTTpqB" +} +``` + +#### Response + +##### 200 Success +(empty response) + +##### 404 Not Found +the provided token is invalid or expired + + +### POST /sessions/close - closes the session + +#### Request body + +| Parameter | Type | Description | +| --------- | ------- | ---------------------------------------------------- | +| boardId | Integer | The id of the opened board | +| token | String | The session token from the /sessions/create response | + +```json +{ + "boardId": 123, + "token":"LCGVgzFZBTMXPfcSVuWmrqLR0j8ZG5o1PpVLeHgTHZ5+4jOJNxlzUZ6ZfPbTTpqB" +} +``` + +#### Response + +##### 200 Success +(empty response) + + # OCS API The following endpoints are available through the Nextcloud OCS endpoint, which is available at `/ocs/v2.php/apps/deck/api/v1.0/`. diff --git a/lib/Controller/SessionController.php b/lib/Controller/SessionController.php index c42cb7b46..c273de1ac 100644 --- a/lib/Controller/SessionController.php +++ b/lib/Controller/SessionController.php @@ -73,7 +73,7 @@ class SessionController extends ApiController { $this->sessionService->syncSession($boardId, $token); return new DataResponse([]); } catch (DoesNotExistException $e) { - return new DataResponse([], 403); + return new DataResponse([], 404); } }