From b48411a9de843186e6435f8d69f2d4a61039c81b Mon Sep 17 00:00:00 2001 From: Bhavika Tibrewal Date: Sun, 30 Apr 2023 07:42:09 +0000 Subject: [PATCH 1/2] `update API contract for inDiscord feature --- users/README.md | 114 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 101 insertions(+), 13 deletions(-) diff --git a/users/README.md b/users/README.md index 9792c15d..06fc3b0b 100644 --- a/users/README.md +++ b/users/README.md @@ -34,15 +34,18 @@ number and email address. ## **Requests** -| Route | Description | -| :-------------------------------------------------: | :----------------------------------: | -| [GET /users](#get-users) | Returns all users in the system | -| [GET /users/self](#get-usersSelf) | Returns the logged in user's details | -| [GET /users/userId/:userId](#get-usersuseriduserid) | Returns user with given userId | -| [GET /users/:username](#get-usersusername) | Returns user with given username | -| [GET /users/:userId/badges](#get-usersidbadges) | Returns badges assigned to the user | -| [POST /users](#post-users) | Creates a new User | -| [PATCH /users/self](#patch-usersself) | Updates data of the User | +| Route | Description | +| :-------------------------------------------------: | :------------------------------------------------: | +| [GET /users](#get-users) | Returns all users in the system | +| [GET /users/self](#get-usersSelf) | Returns the logged in user's details | +| [GET /users/userId/:userId](#get-usersuseriduserid) | Returns user with given userId | +| [GET /users/:username](#get-usersusername) | Returns user with given username | +| [GET /users/:userId/badges](#get-usersidbadges) | Returns badges assigned to the user | +| [POST /users](#post-users) | Creates a new User | +| [PATCH /users/self](#patch-usersself) | Updates data of the User | +| [POST /users/sync-inDiscord](#post-sync-inDiscord) | Sync RDS users inDiscord role with Discord members | +| [GET /users/inDiscord](#get-usersinDiscord) | Get RDS users with role: inDiscord = true | +| [GET /users/verified](#get-usersverified) | Get RDS users who are verified | ## **GET /users** @@ -50,15 +53,15 @@ Returns all users in the system. - **Params** None -- **Query** +- **Query** - Optional: `size=[integer]` (`size` is number of users requested per page, - value ranges in between 1-100, and default value is 100) + value ranges in between 1-100, and default value is 100) - Optional: `page=[integer]` - (`page` can either be 0 or positive-number, and default value is 0) + (`page` can either be 0 or positive-number, and default value is 0) - Optional: `search=[string]` (`search` is a string value for username prefix) - Optional: `next=[string]` (`next` is id of the DB document to get next batch/page of results after that document.) - Optional: `prev=[string]` (`prev` is id of the DB document to get previous batch/page of results before that document.) - - Optional: `query=[string]` ( `query` can be used to filter and/or sort users based on their PR and Issue status within a given date range. [Learn more](https://github.com/Real-Dev-Squad/website-backend/wiki/Filter-and-sort-users-based-on-PRs-and-Issues) ) + - Optional: `query=[string]` ( `query` can be used to filter and/or sort users based on their PR and Issue status within a given date range. [Learn more](https://github.com/Real-Dev-Squad/website-backend/wiki/Filter-and-sort-users-based-on-PRs-and-Issues) ) - **Body** None - **Headers** @@ -265,3 +268,88 @@ Updates data of the User. - **Code:** 503 - **Content:** `{ 'statusCode': 503, 'error': 'Service Unavailable', 'message': 'Something went wrong please contact admin' }` + +## **POST /users/sync-inDiscord** + +It makes an API call to DISCORD_BOT and fetches a list of discord members and updates the **inDiscord** role for that users in our databse. + +- **Params** + None +- **Query** + None +- **Headers** + Content-Type: application/json +- **Cookie** + rds-session: `` +- **Authorize Roles:** SUPERUSER +- **Body** +None +- **Success Response:** + - **Code:** 204 + - **Content:** `{ 'message': 'Users data updated successfully!'}` + - **Code:** 401 + - **Content:** + `{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }` + - **Code:** 503 + - **Content:** + `{ 'statusCode': 503, 'error': 'Service Unavailable', 'message': 'Something went wrong please contact admin' }` + +## **GET /users/inDiscord** +GET RDS users with role: inDiscord=true + + - **Params** + None + - **Query** + None + - **Body** + None + - **Headers** + Content-Type: application/json + - **Cookie** + rds-session: `` + - **Success Response:** + - **Code:** 200 + - **Content:** + + ``` + { + message: 'Users returned successfully!' + users: [ + {} + ] + } + ``` + + ## **GET /users/verified** +GET RDS users who are verified + + - **Params** + None + - **Query** + None + - **Body** + None + - **Headers** + Content-Type: application/json + - **Cookie** + rds-session: `` + - **Success Response:** + - **Code:** 200 + - **Content:** + + ``` + { + message: 'Users returned successfully!' + users: [ + {} + ] + } + ``` + - **Error Response:** + - **Code:** 401 + - **Content:** + `{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }` + + - **Code:** 500 + - **Content:** + `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }` \ No newline at end of file From 40a31bf1516698c6d81830e22826b7ccc747c927 Mon Sep 17 00:00:00 2001 From: Bhavika Tibrewal Date: Wed, 17 May 2023 19:10:23 +0530 Subject: [PATCH 2/2] doc: changed /inDiscord and /verfied to /search --- users/README.md | 46 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/users/README.md b/users/README.md index 06fc3b0b..c5c38343 100644 --- a/users/README.md +++ b/users/README.md @@ -43,9 +43,9 @@ number and email address. | [GET /users/:userId/badges](#get-usersidbadges) | Returns badges assigned to the user | | [POST /users](#post-users) | Creates a new User | | [PATCH /users/self](#patch-usersself) | Updates data of the User | -| [POST /users/sync-inDiscord](#post-sync-inDiscord) | Sync RDS users inDiscord role with Discord members | -| [GET /users/inDiscord](#get-usersinDiscord) | Get RDS users with role: inDiscord = true | -| [GET /users/verified](#get-usersverified) | Get RDS users who are verified | +| [POST /users/](#) | Sync RDS users inDiscord role with Discord members | +| [GET /users//search/](#) | Search RDS users | + ## **GET /users** @@ -269,7 +269,7 @@ Updates data of the User. - **Content:** `{ 'statusCode': 503, 'error': 'Service Unavailable', 'message': 'Something went wrong please contact admin' }` -## **POST /users/sync-inDiscord** +## **POST /users** It makes an API call to DISCORD_BOT and fetches a list of discord members and updates the **inDiscord** role for that users in our databse. @@ -294,13 +294,14 @@ None - **Content:** `{ 'statusCode': 503, 'error': 'Service Unavailable', 'message': 'Something went wrong please contact admin' }` -## **GET /users/inDiscord** +## **GET /users/search/** GET RDS users with role: inDiscord=true - **Params** None - **Query** - None + Optional: `role=string` + Optional: `verified=true` - **Body** None - **Headers** @@ -320,36 +321,3 @@ GET RDS users with role: inDiscord=true } ``` - ## **GET /users/verified** -GET RDS users who are verified - - - **Params** - None - - **Query** - None - - **Body** - None - - **Headers** - Content-Type: application/json - - **Cookie** - rds-session: `` - - **Success Response:** - - **Code:** 200 - - **Content:** - - ``` - { - message: 'Users returned successfully!' - users: [ - {} - ] - } - ``` - - **Error Response:** - - **Code:** 401 - - **Content:** - `{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }` - - - **Code:** 500 - - **Content:** - `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }` \ No newline at end of file