From 6284b3624ea60e5e8a137554dbeeabe8843abb28 Mon Sep 17 00:00:00 2001 From: Dash Deipayan Date: Sat, 13 May 2023 17:39:05 +0530 Subject: [PATCH 1/4] added api contract for discord actions --- README.md | 1 + discordactions/README.md | 103 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 discordactions/README.md diff --git a/README.md b/README.md index df13066..e6e68af 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,4 @@ - [Users](/users) - [Badges](/badges) - [CloudflareCache](/cloudflare-cache) +- [Discord-actions](/discordactions) diff --git a/discordactions/README.md b/discordactions/README.md new file mode 100644 index 0000000..ae49c12 --- /dev/null +++ b/discordactions/README.md @@ -0,0 +1,103 @@ +# Discord actions + + +## **Requests** + +| Route | Description | +|:------------------------------------------------------:|:-----------------------------:| +| [GET /groups](#get-groups) | Returns all group roles | +| [POST /groups](#post-groups) | Creates new group role | +| [POST /roles](#post-roles) | Adds a group role to a user | + +## **GET /groups** + +> returns all group roles + +## Response + +```json +{ + "message":"Roles fetched successfully!", + "groups":[ + { + "id":"BcfrtGo9hAhVxcDZ5ADQ", + "date":{ + "_seconds":1683970114, + "_nanoseconds":286000000 + }, + "createdBy":"k15z2SLFe1U2J3gshXUG", + "rolename":"group-peer-programming", + "roleid":"1106875628000653332" + }, + { + "id":"ELqELhWrdoSX1AusBwPw", + "date":{ + "_seconds":1683917265, + "_nanoseconds":874000000 + }, + "createdBy":"1uilsoHQZ1TzcYyy25BA", + "rolename":"group-live-site", + "roleid":"1106653965799657533" + }, + ] +} + +``` + + +## **POST /group** +> creates a new group role +## Body + +```json +{ + "rolename": "some-demo" +} +``` + +## Response + + +- **Error Response:** + - **Code:** 400 + - **Content:** + ```json + { + "statusCode": 400, + "error": "BAD REQUEST", + "message": "Role already exists" + } + ``` + +## **POST /roles** + +> This request allows users to add group-roles to themselves + +## Body + +Request + +```json + { + "userid": "", + "roleid": "" + } +``` + +Response + +```json +{ + "message": "Role added successfully!" +} +``` +- **Error Response:** + - **Code:** 404 + - **Content:** + ```json + { + "statusCode": 400, + "error": "BAD REQUEST", + "message": "Role already exists!" + } + ``` From 4f1d72dbe5419ce5939fd8fdb233c523326adffe Mon Sep 17 00:00:00 2001 From: Dash Deipayan Date: Sat, 13 May 2023 23:22:57 +0530 Subject: [PATCH 2/4] added error code --- discordactions/README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/discordactions/README.md b/discordactions/README.md index ae49c12..ff8988d 100644 --- a/discordactions/README.md +++ b/discordactions/README.md @@ -43,7 +43,16 @@ } ``` - +- **Error Response:** + - **Code:** 500 + - **Content:** + ```json + { + "statusCode": 400, + "error": "INTERNAL SERVER ERROR", + "message": "Internal server error" + } + ``` ## **POST /group** > creates a new group role @@ -92,7 +101,7 @@ Response } ``` - **Error Response:** - - **Code:** 404 + - **Code:** 400 - **Content:** ```json { From 84f311a3ebe97a2e0286b1b8519e6f50cde512a0 Mon Sep 17 00:00:00 2001 From: Dash Deipayan Date: Sat, 13 May 2023 23:24:32 +0530 Subject: [PATCH 3/4] added 404 --- discordactions/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/discordactions/README.md b/discordactions/README.md index ff8988d..b526feb 100644 --- a/discordactions/README.md +++ b/discordactions/README.md @@ -53,6 +53,15 @@ "message": "Internal server error" } ``` + - **Code:** 404 + - **Content:** + ```json + { + "statusCode": 404, + "error": "NOT FOUND", + "message": "Not found" + } + ``` ## **POST /group** > creates a new group role From 4f4c1268c17427461557b99c4c2a748999498727 Mon Sep 17 00:00:00 2001 From: Dash Deipayan Date: Sun, 14 May 2023 01:43:42 +0530 Subject: [PATCH 4/4] Fixed error codes --- discordactions/README.md | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/discordactions/README.md b/discordactions/README.md index b526feb..409feb2 100644 --- a/discordactions/README.md +++ b/discordactions/README.md @@ -5,9 +5,9 @@ | Route | Description | |:------------------------------------------------------:|:-----------------------------:| -| [GET /groups](#get-groups) | Returns all group roles | -| [POST /groups](#post-groups) | Creates new group role | -| [POST /roles](#post-roles) | Adds a group role to a user | +| [GET /groups](#get-groups) | Returns all group roles | +| [POST /groups](#post-groups) | Creates new group role | +| [POST /roles](#post-roles) | Adds group role to a user | | ## **GET /groups** @@ -48,7 +48,7 @@ - **Content:** ```json { - "statusCode": 400, + "statusCode": 500, "error": "INTERNAL SERVER ERROR", "message": "Internal server error" } @@ -86,6 +86,15 @@ "message": "Role already exists" } ``` + - **Code:** 500 + - **Content:** + ```json + { + "statusCode": 500, + "error": "INTERNAL SERVER ERROR", + "message": "Internal server error!" + } + ``` ## **POST /roles** @@ -96,17 +105,17 @@ Request ```json - { - "userid": "", - "roleid": "" - } +{ + "userid": "", + "roleid": "" +} ``` Response ```json { - "message": "Role added successfully!" + "message": "Role added successfully!" } ``` - **Error Response:** @@ -119,3 +128,12 @@ Response "message": "Role already exists!" } ``` + - **Code:** 500 + - **Content:** + ```json + { + "statusCode": 500, + "error": "INTERNAL SERVER ERROR", + "message": "Internal server error!" + } + ```