Skip to content

Commit fca856e

Browse files
API contract update for the pagination method enhancement on the users state API (#176)
* add pagination on the users state API * add: update the API contract for the pagination method on users state API * add: update the API contract for the pagination method on users state API * add: update the API contract for the pagination method on users state API * add: update the API contract for the pagination method on users state API add more fields * add: update the API contract for the pagination method on users state API add route on the table * add: add users state and verified value
1 parent 5dbd000 commit fca856e

File tree

1 file changed

+75
-21
lines changed

1 file changed

+75
-21
lines changed

users/README.md

Lines changed: 75 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ number and email address.
4343
| [GET /users/userId/:userId](#get-usersuseriduserid) | Returns user with given userId |
4444
| [GET /users/:username](#get-usersusername) | Returns user with given username |
4545
| [GET /users/:userId/badges](#get-usersidbadges) | Returns badges assigned to the user |
46+
| [GET /users/search](#get-users-search) | Returns users based on specified filters |
4647
| [POST /users](#post-users) | Creates a new User |
4748
| [PATCH /users/self](#patch-usersself) | Updates data of the User |
4849
| [PATCH /users/:id/temporary/data](#patch-usersidroles) | Updates user roles |
@@ -55,36 +56,34 @@ Returns all users in the system.
5556
- **Params**
5657
None
5758
- **Query**
58-
- Optional: `size=[integer]` (`size` is number of users requested per page,
59-
value ranges in between 1-100, and default value is 100)
60-
- Optional: `page=[integer]`
61-
(`page` can either be 0 or positive-number, and default value is 0)
59+
- Optional: `size=[integer]` (`size` is the number of users requested per page, value ranges between 1-100, and the default value is 100)
60+
- Optional: `page=[integer]` (`page` can either be 0 or a positive number, and the default value is 0)
6261
- Optional: `search=[string]` (`search` is a string value for username prefix)
63-
- Optional: `next=[string]` (`next` is id of the DB document to get next batch/page of results after that document.)
64-
- Optional: `prev=[string]` (`prev` is id of the DB document to get previous batch/page of results before that document.)
65-
- 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) )
62+
- Optional: `next=[string]` (`next` is the id of the DB document to get the next batch/page of results after that document.)
63+
- Optional: `prev=[string]` (`prev` is the id of the DB document to get the previous batch/page of results before that document.)
64+
- 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) )
6665
- **Body**
6766
None
6867
- **Headers**
6968
Content-Type: application/json
7069
- **Cookie**
7170
rds-session: `<JWT>`
7271
- **Success Response:**
73-
- **Code:** 200
74-
- **Content:**
72+
- **Code:** 200
73+
- **Content:**
7574

76-
```
77-
{
78-
message: 'Users returned successfully!'
79-
users: [
80-
{<user_object>}
81-
]
82-
links: {
83-
next: '/users?next={<DB document id>}&size={number}&search={string}',
84-
prev: '/users?prev={<DB document id>}&size={number}&search={string}'
85-
}
86-
}
87-
```
75+
```
76+
{
77+
"message": "Users returned successfully!",
78+
"users": [
79+
{ <user_object> }
80+
],
81+
"links": {
82+
"next": '/users?next={<DB document id>}&size={number}&search={string}',
83+
"prev": '/users?prev={<DB document id>}&size={number}&search={string}'
84+
}
85+
}
86+
```
8887
8988
- **Error Response:**
9089
- **Code:** 401
@@ -216,6 +215,61 @@ Returns badges assigned to the user
216215
- **Content:**
217216
`{ 'statusCode': 400, 'error': 'Bad Request', 'message': 'Failed to get user badges.' }`
218217
218+
## **GET /users/search**
219+
220+
Returns users based on the specified filters.
221+
222+
- **Params:**
223+
None
224+
225+
- **Query Parameters:**
226+
- Optional: `levelId=[string]` (Specifies the level ID)
227+
- Optional: `levelName=[string]` (Specifies the level name)
228+
- Optional: `levelValue=[number]` (Specifies the level value)
229+
- Optional: `tagId=[string]` (Specifies the tag ID)
230+
- Optional: `state=[string]` (Specifies the user state. Possible values: "ACTIVE", "OOO", "IDLE", "ONBOARDING", "ONBOARDING31DAYS". This parameter can be repeated for multiple states.)
231+
- Optional: `role=[string]` (Specifies the user role, valid values are "MEMBER", "INDISCORD", "ARCHIVED")
232+
- Optional: `verified=[string]` (Specifies if the user is verified. Possible values: "true", "false")
233+
- Optional: `time=[string]` (Specifies the time filter, e.g., "31d")
234+
235+
- **Body:**
236+
None
237+
238+
- **Headers:**
239+
Content-Type: application/json
240+
rds-session: `<JWT>`
241+
242+
- **Success Response:**
243+
- **Code:** 200
244+
- **Content:**
245+
246+
```
247+
{
248+
"message": "Users found successfully!",
249+
"users": [
250+
{ <user_object> }
251+
],
252+
"links": {
253+
"next": "/users/search?next={<DB document id>}&page={number}&size={number}&dev={boolean}&state=ACTIVE&state=OOO&state=IDLE&state=ONBOARDING&time=31d",
254+
"prev": "/users/search?prev={<DB document id>}&page={number}&size={number}&dev={boolean}&state=ACTIVE&state=OOO&state=IDLE&state=ONBOARDING&time=31d"
255+
},
256+
"count": Number
257+
}
258+
```
259+
260+
- **Error Response:**
261+
- **Code:** 400
262+
- **Content:**
263+
`{ 'statusCode': 400, 'error': 'Bad Request', 'message': 'Filter for item not provided' }`
264+
265+
- **Code:** 401
266+
- **Content:**
267+
`{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }`
268+
269+
- **Code:** 503
270+
- **Content:**
271+
`{ 'statusCode': 503, 'error': 'Service Unavailable', 'message': 'Something went wrong, please contact admin' }`
272+
219273
## **POST /users**
220274
221275
Creates a new User.

0 commit comments

Comments
 (0)