Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update API contract for inDiscord feature #123

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 69 additions & 13 deletions users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,34 @@ 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 RDS users inDiscord role with Discord members |
| [GET /users//search/](#) | Search RDS users |


## **GET /users**

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**
Expand Down Expand Up @@ -265,3 +268,56 @@ Updates data of the User.
- **Code:** 503
- **Content:**
`{ 'statusCode': 503, 'error': 'Service Unavailable', 'message': 'Something went wrong please contact admin' }`

## **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.

- **Params**
None
- **Query**
None
- **Headers**
Content-Type: application/json
- **Cookie**
rds-session: `<JWT>`
- **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/search/**
GET RDS users with role: inDiscord=true

- **Params**
None
- **Query**
Optional: `role=string`
Optional: `verified=true`
- **Body**
None
- **Headers**
Content-Type: application/json
- **Cookie**
rds-session: `<JWT>`
- **Success Response:**
- **Code:** 200
- **Content:**

```
{
message: 'Users returned successfully!'
users: [
{<user_object>}
]
}
```