From 618ca0053829cd002f423577dd648cd49a356f45 Mon Sep 17 00:00:00 2001 From: vinayak Date: Mon, 18 Sep 2023 21:45:15 +0530 Subject: [PATCH 1/5] API contract for discord API --- discord/README.md | 139 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 discord/README.md diff --git a/discord/README.md b/discord/README.md new file mode 100644 index 0000000..4c3b0e2 --- /dev/null +++ b/discord/README.md @@ -0,0 +1,139 @@ +# discord + + +## invite object + +```json +{ + "userId": "string", + "invite": "string", + "timestamp": "" +} +``` + +## **Requests** + +| Route | Description | +| :--------------------------: | :-----------------------: | +| [GET /discord/invites](#get-discord-invites) | return all the invites generated | +[POST /discord/invites](#post-discord-invites) | generates a invite for a user | +--- + +## **GET /discord/invites** + +- This API can only be accessed by super user and if the query param contains userId and the userId matches the userId of the user then it return the invite generated by that user + +returns all the invites if there is no query param sent in the url, if there is a query param userId it return invite generated for a particulat user + +- **Query** + + - Optional: `userId=[string]`: if this is provided it returns the invite for a pariticular user if the userId of the user matches the userId in query param, or the user is super user, other it return 403 + +- **Headers** + None +- **Cookie** + rds-session: `` + +- **Success Response:** + + - **Code:** 200 + - **Content:** + ```json + { + "message": "invite returned successfully" || "invites returned successfully", + "invite": [", "] || "" + } + ``` + +- **Error Responses:** + - **Code:** 401 + - **Content:** + ```json + { + "statusCode": 401, + "error": "Unauthorized", + "message": "You are not authorized for this action." + } + ``` + - **Code:** 403 + + - **Content:** + ```json + { + "message": "You do not have permission to access this resource." + } + ``` + - **Code:** 404 + + - **Content:** + ```json + { + "message": "User not found." + } + ``` + - **Code:** 500 + - **Content:** + ```json + { + "statusCode": 500, + "error": "Internal Server Error", + "message": "Something went wrong. Please contact admin" + } + ``` + +## **POST /discord/invites** + +- This Api is used to create a discord invite for the user, invite for a particular user can be generated by a super user or a that user only, invite for a particular user can be created only once + +- **Params**\ + None +- **Query**\ + None +- **Body**\ + `{ userId: }` +- **Headers**\ + None +- **Cookie**\ + None +- **Success Response:** + - **Code:** 201 + - **Content:** + ```json + { + "message": "Invite created successfully." + } + ``` + - **Code:** 401 + - **Content:** + ```json + { + "statusCode": 401, + "error": "Unauthorized", + "message": "Unauthenticated user" + } + ``` + - **Code:** 404 + - **Content:** + ```json + { + "message": "user doesn't exist" + } + ``` + - **Code:** 409 + - **Content:** + ```json + { + "message": "invite already exists" + } + ``` + +- **Error Response:** + - **Code:** 500 + - **Content:** + ```json + { + "statusCode": 500, + "error": "Internal Server Error", + "message": "An internal server error occurred" + } + ``` From 4a064c5ca5ef0be4f5944f1440c8d59ba438439d Mon Sep 17 00:00:00 2001 From: vinayak Date: Sun, 8 Oct 2023 17:21:09 +0530 Subject: [PATCH 2/5] discord invite API contract --- {discord => discord-actions}/README.md | 38 ++++++++++---------------- 1 file changed, 15 insertions(+), 23 deletions(-) rename {discord => discord-actions}/README.md (63%) diff --git a/discord/README.md b/discord-actions/README.md similarity index 63% rename from discord/README.md rename to discord-actions/README.md index 4c3b0e2..56eed4a 100644 --- a/discord/README.md +++ b/discord-actions/README.md @@ -5,9 +5,9 @@ ```json { + "id": "string", + "inviteLink": "string", "userId": "string", - "invite": "string", - "timestamp": "" } ``` @@ -15,19 +15,17 @@ | Route | Description | | :--------------------------: | :-----------------------: | -| [GET /discord/invites](#get-discord-invites) | return all the invites generated | -[POST /discord/invites](#post-discord-invites) | generates a invite for a user | +| [GET /discord/invites](#get-discord-actions-invites) | return all the invites generated | +[POST /discord/invites](#post-discord-actions -invites) | generates a invite for a user | --- -## **GET /discord/invites** +## **GET /discord-actions/invite** -- This API can only be accessed by super user and if the query param contains userId and the userId matches the userId of the user then it return the invite generated by that user - -returns all the invites if there is no query param sent in the url, if there is a query param userId it return invite generated for a particulat user +- return the discord invite created for the user - **Query** - - Optional: `userId=[string]`: if this is provided it returns the invite for a pariticular user if the userId of the user matches the userId in query param, or the user is super user, other it return 403 + - Optional: `userId=[string]`: if this is provided it returns the invite of the user whose userId is provided in the query param, if the user is not a super user then this should be equal to the userId of the user, if no userId is provided, it return invite for the user who has made the request - **Headers** None @@ -40,8 +38,8 @@ returns all the invites if there is no query param sent in the url, if there is - **Content:** ```json { - "message": "invite returned successfully" || "invites returned successfully", - "invite": [", "] || "" + "message": "Invite return successfully!", + "inviteResponse": "" } ``` @@ -68,7 +66,7 @@ returns all the invites if there is no query param sent in the url, if there is - **Content:** ```json { - "message": "User not found." + "message": "Invite not found for user!" } ``` - **Code:** 500 @@ -88,9 +86,9 @@ returns all the invites if there is no query param sent in the url, if there is - **Params**\ None - **Query**\ - None + - Optional: `userId=[string]`: if this is provided it create the invite for that userId if the user is a super user, if this is not provided it create invite for the user making the request - **Body**\ - `{ userId: }` + None - **Headers**\ None - **Cookie**\ @@ -100,7 +98,8 @@ returns all the invites if there is no query param sent in the url, if there is - **Content:** ```json { - "message": "Invite created successfully." + "message": "Invite created successfully.", + "inviteLink": "string", } ``` - **Code:** 401 @@ -112,18 +111,11 @@ returns all the invites if there is no query param sent in the url, if there is "message": "Unauthenticated user" } ``` - - **Code:** 404 - - **Content:** - ```json - { - "message": "user doesn't exist" - } - ``` - **Code:** 409 - **Content:** ```json { - "message": "invite already exists" + "message": "User invite is already present!" } ``` From 0d3612ab072eab682585c4422b0618a55dab89ef Mon Sep 17 00:00:00 2001 From: vinayak Date: Wed, 1 Nov 2023 21:34:18 +0530 Subject: [PATCH 3/5] change in response --- discord-actions/README.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/discord-actions/README.md b/discord-actions/README.md index 56eed4a..f5b3c39 100644 --- a/discord-actions/README.md +++ b/discord-actions/README.md @@ -1,15 +1,4 @@ -# discord - - -## invite object - -```json -{ - "id": "string", - "inviteLink": "string", - "userId": "string", -} -``` +# discord-actions ## **Requests** @@ -39,7 +28,7 @@ ```json { "message": "Invite return successfully!", - "inviteResponse": "" + "inviteLink": "discord_invite_link_here" } ``` From 00afceeb474c8b35bd9a4253895f2996b23749fd Mon Sep 17 00:00:00 2001 From: vinayak Date: Thu, 23 Nov 2023 07:02:43 +0530 Subject: [PATCH 4/5] updated api contract for discord invite --- discord-actions/README.md | 89 ++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/discord-actions/README.md b/discord-actions/README.md index f5b3c39..f23242b 100644 --- a/discord-actions/README.md +++ b/discord-actions/README.md @@ -2,10 +2,11 @@ ## **Requests** -| Route | Description | -| :--------------------------: | :-----------------------: | -| [GET /discord/invites](#get-discord-actions-invites) | return all the invites generated | -[POST /discord/invites](#post-discord-actions -invites) | generates a invite for a user | +| Route | Description | +| :-----------------------------------------------------: | :------------------------------: | +| [GET /discord/invites](#get-discord-actions-invites) | return all the invites generated | +| [POST /discord/invites](#post-discord-actions -invites) | generates a invite for a user | + --- ## **GET /discord-actions/invite** @@ -28,11 +29,12 @@ ```json { "message": "Invite return successfully!", - "inviteLink": "discord_invite_link_here" + "inviteLink": "discord_invite_link_here" } ``` - **Error Responses:** + - **Code:** 401 - **Content:** ```json @@ -58,6 +60,7 @@ "message": "Invite not found for user!" } ``` + - **Code:** 500 - **Content:** ```json @@ -70,51 +73,69 @@ ## **POST /discord/invites** -- This Api is used to create a discord invite for the user, invite for a particular user can be generated by a super user or a that user only, invite for a particular user can be created only once +- This Api is used to create a discord invite for the user, invite for a particular user can be generated by a super user or a that user only, invite for a particular user can be created only once, Following conditions will be there for creating invite for the user: +- The user should not be archieved +- The user should have one of these roles, if they want to directly generate a invite: product_manager, designer, maven +- If they don't have the roles mentioned above, they should have profileStatus approved - **Params**\ - None + None - **Query**\ - - Optional: `userId=[string]`: if this is provided it create the invite for that userId if the user is a super user, if this is not provided it create invite for the user making the request + - Optional: `userId=[string]`: if this is provided it create the invite for that userId if the user is a super user, if this is not provided it create invite for the user making the request - **Body**\ - None + None - **Headers**\ - None + None - **Cookie**\ - None + None - **Success Response:** - - **Code:** 201 - - **Content:** - ```json - { - "message": "Invite created successfully.", - "inviteLink": "string", - } - ``` + + - **Code:** 201 + - **Content:** + ```json + { + "message": "Invite created successfully.", + "inviteLink": "string" + } + ``` - **Code:** 401 - **Content:** ```json - { - "statusCode": 401, - "error": "Unauthorized", - "message": "Unauthenticated user" - } + { + "statusCode": 401, + "error": "Unauthorized", + "message": "Unauthenticated user" + } ``` - **Code:** 409 + - **Content:** ```json - { - "message": "User invite is already present!" + { + "message": "User invite is already present!" + } + ``` + + - **Code:** 403 + - **Content:** + ```json + { + "statusCode": 403, + "error": "Forbidden", + "message": "User should be super user to generate link for other users" "||" "Only users who have never joined discord can generate invite link" "||" "Archived users cannot generate invite" "||" "Only selected roles can generate discord link directly" } ``` - **Error Response:** - - **Code:** 500 - - **Content:** - ```json - { - "statusCode": 500, - "error": "Internal Server Error", - "message": "An internal server error occurred" - } + - **Code:** 500 + - **Content:** + ```json + { + "statusCode": 500, + "error": "Internal Server Error", + "message": "An internal server error occurred" + } ``` + ``` + + ``` From 2c24972a71f76e6c3d268ec1f594d91e38a7b9f1 Mon Sep 17 00:00:00 2001 From: vinayak Date: Thu, 23 Nov 2023 07:06:37 +0530 Subject: [PATCH 5/5] fixed endpoint name --- discord-actions/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord-actions/README.md b/discord-actions/README.md index f23242b..200193b 100644 --- a/discord-actions/README.md +++ b/discord-actions/README.md @@ -4,8 +4,8 @@ | Route | Description | | :-----------------------------------------------------: | :------------------------------: | -| [GET /discord/invites](#get-discord-actions-invites) | return all the invites generated | -| [POST /discord/invites](#post-discord-actions -invites) | generates a invite for a user | +| [GET /discord-actions/invites](#get-discord-actions-invites) | return all the invites generated | +| [POST /discord-actions/invites](#post-discord-actions-invites) | generates a invite for a user | ---