generated from RealDevSquad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 49
add: contracts for questions and answers word cloud feature #166
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
486e64e
add: contracts for post request of question
satyam73 fb6e155
add: questions and answers contracts
satyam73 d269a31
fix: api contracts typo and response objects
satyam73 ff3bd82
fix: max_words to max_characters
satyam73 60bcf23
chore: fix types of event_id and spaces
satyam73 66130a0
chore: remove unnecessary headers and fix contracts
satyam73 c87ac8a
fix: answers api contracts for rejected case
satyam73 0cad03a
chore: fix formatting
satyam73 c15d702
chore: remove unnecessary property
satyam73 6bf2860
chore: remove unnecessary headings and fix some keys
satyam73 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| # ANSWERS | ||
|
|
||
| | Method | Route | Description | | ||
| | ------ | ----------------------------------------------- | -------------------------------------------------------------- | | ||
| | POST | [/answers](#post---answers) | it will be to submit answer by the peers | | ||
| | PATCH | [/answers/:answerId](#patch---answers-answerid) | for updating the answers(will primarily be using for approval) | | ||
| | GET | [/answers](#get---answers) | it will be to get the answers | | ||
|
|
||
| ### Status description | ||
|
|
||
| `PENDING` - peer has submitted the answer but haven't got any review on the answer yet. | ||
|
|
||
| `APPROVED` - if host/moderator has approved the answer | ||
|
|
||
| `REJECTED` - if host/moderator has rejected the answer | ||
|
|
||
| ### POST - /answers | ||
|
|
||
| It will be used for peers to answer questions. | ||
|
|
||
| - **Params:** | ||
| - None | ||
| - **Query** | ||
| - None | ||
| - **Body** | ||
| - **`answer=[STRING]`** required - (The answer text) | ||
| - **`answeredBy=[STRING]`** required (The ID of the peer who answered the question.) | ||
satyam73 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - **`eventId=[STRING]`** required (The ID of the event where the question was asked.) | ||
| - **`questionId=[STRING]`** required (The ID of the question for which the answer is.) | ||
| - **Headers** | ||
| - n/a | ||
| - **Cookie** | ||
| - none | ||
| - **Success Response:** | ||
|
|
||
| - **Status Code:** 201 CREATED | ||
| - **Content:** | ||
|
|
||
| ```json | ||
| { | ||
| "message": "Answer submitted successfully", | ||
| "data": { | ||
| "id": "<STRING>", | ||
| "answer": "<STRING>", | ||
| "status": "<STRING>", //(can be PENDING, APPROVED,REJECTED) //so that HOST | MODERATOR can filter out the answers which has to be shown in word cloud | ||
| "reviewed_by": "<RDS_USER_ID> || null", //can be of HOST | MODERATOR | ||
| "question_id": "<STRING>", //FOREIGN KEY POINTING TO QUESTION COLLECTION | ||
| "answered_by": "<STRING>", //ID OF THE RESPONDER OF THE QUESTION(FROM PEERS COLLECTION) | ||
| "event_id": "<STRING>", //ID OF THE EVENT IN WHICH ANSWER IS GIVEN | ||
| "created_at": "TIMESTAMP", | ||
| "updated_at": "TIMESTAMP" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - **Error Response:** | ||
|
|
||
| - **Status Code:** 500 INTERNAL_SERVER_ERROR | ||
| - **Content:** | ||
|
|
||
| ```json | ||
| { | ||
| "statusCode": 500, | ||
| "error": "Internal Server Error", | ||
| "message": "An internal server error occurred" | ||
| } | ||
| ``` | ||
|
|
||
| ### PATCH - /answers/:answerId | ||
|
|
||
| It will be used to update the answers. | ||
|
|
||
| - **Params:** | ||
| - None | ||
| - **Query** | ||
| - None | ||
| - **Body** | ||
| - **`status=[STRING]`** optional | ||
| - **Headers** | ||
| - n/a | ||
| - **Cookie** | ||
| - `rds-session` - for member or super user only | ||
| - **Success Response:** | ||
| - **Status Code:** 204 No content | ||
| - **Content: n/a** | ||
| - **Error Response:** | ||
| - **Code:** 401 UNAUTHORIZED | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "statusCode": 401, | ||
| "error": "Unauthorized", | ||
| "message": "You are not authorized for this action." | ||
| } | ||
| ``` | ||
| - **Code:** 500 INTERNAL_SERVER_ERROR | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "statusCode": 500, | ||
| "error": "Internal Server Error", | ||
| "message": "An internal server error occurred" | ||
| } | ||
| ``` | ||
|
|
||
| <aside> | ||
| 📌 `reviewed_by` will be taken from `req.userData` in backend | ||
| </aside> | ||
|
|
||
| ### GET - /answers | ||
|
|
||
| It will be used to get all the answers in realtime. | ||
|
|
||
| - **Params:** | ||
| - None | ||
| - **Query** | ||
| - `status` - `<STRING>` | ||
| - `eventId` - `<STRING>` | ||
| - `questionId` - `<STRING>` | ||
| - **Body** | ||
| - none | ||
| - **Headers** | ||
| - Content-Type: 'text/event-stream' | ||
| - Connection: 'keep-alive' | ||
| - Cache-Control: 'no-cache' | ||
| - **Cookie** | ||
| - none | ||
| - **Success Response:** | ||
| - **Status Code:** 200 OK | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "message": "Answers returned successfully", | ||
| "data": [ | ||
| { | ||
| "id": "<STRING>", | ||
| "answer": "<STRING>", | ||
| "status": "<STRING>", //(can be PENDING, APPROVED,REJECTED) //so that HOST | MODERATOR can filter out the answers which has to be shown in word cloud | ||
| "reviewed_by": "<RDS_USER_ID> || null", //can be of HOST | MODERATOR | ||
| "question_id": "<STRING>", //FOREIGN KEY POINTING TO QUESTION COLLECTION | ||
| "answered_by": "<STRING>", //ID OF THE RESPONDER OF THE QUESTION(FROM PEERS COLLECTION) | ||
| "event_id": "<STRING>", //ID OF THE EVENT IN WHICH ANSWER IS GIVEN | ||
| "created_at": "TIMESTAMP", | ||
| "updated_at": "TIMESTAMP" | ||
| }, | ||
| { | ||
| "id": "<STRING>", | ||
| "answer": "<STRING>", | ||
| "status": "<STRING>", //(can be PENDING, APPROVED,REJECTED) //so that HOST | MODERATOR can filter out the answers which has to be shown in word cloud | ||
| "reviewed_by": "<RDS_USER_ID> || null", //can be of HOST | MODERATOR | ||
| "question_id": "<STRING>", //FOREIGN KEY POINTING TO QUESTION COLLECTION | ||
| "answered_by": "<STRING>", //ID OF THE RESPONDER OF THE QUESTION(FROM PEERS COLLECTION) | ||
| "event_id": "<STRING>", //ID OF THE EVENT IN WHICH ANSWER IS GIVEN | ||
| "created_at": "TIMESTAMP", | ||
| "updated_at": "TIMESTAMP" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| - **Error Response:** | ||
| - **Code:** 500 INTERNAL_SERVER_ERROR | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "statusCode": 500, | ||
| "error": "Internal Server Error", | ||
| "message": "An internal server error occurred" | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # QUESTIONS - API CONTRACTS | ||
|
|
||
| | Method | Route | Description | | ||
| | ------ | -------------------------------- | --------------------------------------------- | | ||
| | POST | [/questions](#post---questions) | it will be used for host to ask the question. | | ||
| | GET | [ /questions ](#get---questions) | it will be for users to get the question. | | ||
|
|
||
| ### POST - /questions | ||
|
|
||
| It will be used for host to ask the question. | ||
|
|
||
| - **Params:** | ||
| - None | ||
| - **Query** | ||
| - None | ||
| - **Body** | ||
| - **`question=[STRING]`** required - (The question text.) | ||
| - **`createdBy=[STRING]`** required (The ID of the user who asked the question.) | ||
| - **`eventId=[STRING]`** required (The ID of the session where the question was asked.) | ||
| - **`maxCharacters=[NUMBER || null]`** optional | ||
| - **Headers** | ||
| - n/a | ||
| - **Cookie** | ||
| - `rds-session` - for super user or member | ||
| - **Success Response:** | ||
|
|
||
| - **Status Code:** 201 CREATED | ||
| - **Content:** | ||
|
|
||
| ```json | ||
| { | ||
| "message": "Question created successfully", | ||
| "data": { | ||
| "id": "<STRING>", | ||
| "question": "<STRING>", | ||
| "created_by": "<STRING>", | ||
| "event_id": "<STRING>", | ||
| "max_characters": "<NUMBER>", | ||
| "created_at": "TIMESTAMP" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - **Error Response:** | ||
| - **Code:** 401 UNAUTHORIZED | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "statusCode": 401, | ||
| "error": "Unauthorized", | ||
| "message": "You are not authorized for this action." | ||
| } | ||
| ``` | ||
| - **Code:** 500 INTERNAL_SERVER_ERROR | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "statusCode": 500, | ||
| "error": "Internal Server Error", | ||
| "message": "An internal server error occurred" | ||
| } | ||
| ``` | ||
|
|
||
| ### GET - /questions | ||
|
|
||
| It will be used to get the questions in realtime. | ||
|
|
||
| - **Params:** | ||
| - None | ||
| - **Query** | ||
| - `eventId` - `<STRING>` | ||
| - `questionId` - `<STRING>` | ||
| - **Body** | ||
| - `none` | ||
| - **Headers** | ||
| - Content-Type: 'text/event-stream' | ||
| - Connection: 'keep-alive' | ||
| - Cache-Control: 'no-cache' | ||
| - **Cookie** | ||
| - `none` | ||
| - **Success Response:** | ||
| - **Status Code:** 200 OK | ||
| - **Content:** | ||
| ```json | ||
| "data": { | ||
| "id": "<STRING>", | ||
| "question": "<STRING>", | ||
| "event_id": "<STRING>", | ||
| "max_characters": "<NUMBER>", //number of words answer can have for this question | ||
| "created_at": "TIMESTAMP", | ||
| "created_by": "STRING" //ID OF THE CREATOR OF THE QUESTION(FROM RDS USER COLLECTION) | ||
| } | ||
| ``` | ||
| - **Error Response:** | ||
| - **Code:** 500 INTERNAL_SERVER_ERROR | ||
| - **Content:** | ||
| ```json | ||
| { | ||
| "statusCode": 500, | ||
| "error": "Internal Server Error", | ||
| "message": "An internal server error occurred" | ||
| } | ||
| ``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.