|
| 1 | +# ANSWERS |
| 2 | + |
| 3 | +| Method | Route | Description | |
| 4 | +| ------ | ----------------------------------------------- | -------------------------------------------------------------- | |
| 5 | +| POST | [/answers](#post---answers) | it will be to submit answer by the peers | |
| 6 | +| PATCH | [/answers/:answerId](#patch---answers-answerid) | for updating the answers(will primarily be using for approval) | |
| 7 | +| GET | [/answers](#get---answers) | it will be to get the answers | |
| 8 | + |
| 9 | +### Status description |
| 10 | + |
| 11 | +`PENDING` - peer has submitted the answer but haven't got any review on the answer yet. |
| 12 | + |
| 13 | +`APPROVED` - if host/moderator has approved the answer |
| 14 | + |
| 15 | +`REJECTED` - if host/moderator has rejected the answer |
| 16 | + |
| 17 | +### POST - /answers |
| 18 | + |
| 19 | +It will be used for peers to answer questions. |
| 20 | + |
| 21 | +- **Params:** |
| 22 | + - None |
| 23 | +- **Query** |
| 24 | + - None |
| 25 | +- **Body** |
| 26 | + - **`answer=[STRING]`** required - (The answer text) |
| 27 | + - **`answeredBy=[STRING]`** required (The ID of the peer who answered the question.) |
| 28 | + - **`eventId=[STRING]`** required (The ID of the event where the question was asked.) |
| 29 | + - **`questionId=[STRING]`** required (The ID of the question for which the answer is.) |
| 30 | +- **Headers** |
| 31 | + - n/a |
| 32 | +- **Cookie** |
| 33 | + - none |
| 34 | +- **Success Response:** |
| 35 | + |
| 36 | + - **Status Code:** 201 CREATED |
| 37 | + - **Content:** |
| 38 | + |
| 39 | + ```json |
| 40 | + { |
| 41 | + "message": "Answer submitted successfully", |
| 42 | + "data": { |
| 43 | + "id": "<STRING>", |
| 44 | + "answer": "<STRING>", |
| 45 | + "status": "<STRING>", //(can be PENDING, APPROVED,REJECTED) //so that HOST | MODERATOR can filter out the answers which has to be shown in word cloud |
| 46 | + "reviewed_by": "<RDS_USER_ID> || null", //can be of HOST | MODERATOR |
| 47 | + "question_id": "<STRING>", //FOREIGN KEY POINTING TO QUESTION COLLECTION |
| 48 | + "answered_by": "<STRING>", //ID OF THE RESPONDER OF THE QUESTION(FROM PEERS COLLECTION) |
| 49 | + "event_id": "<STRING>", //ID OF THE EVENT IN WHICH ANSWER IS GIVEN |
| 50 | + "created_at": "TIMESTAMP", |
| 51 | + "updated_at": "TIMESTAMP" |
| 52 | + } |
| 53 | + } |
| 54 | + ``` |
| 55 | + |
| 56 | +- **Error Response:** |
| 57 | + |
| 58 | + - **Status Code:** 500 INTERNAL_SERVER_ERROR |
| 59 | + - **Content:** |
| 60 | + |
| 61 | + ```json |
| 62 | + { |
| 63 | + "statusCode": 500, |
| 64 | + "error": "Internal Server Error", |
| 65 | + "message": "An internal server error occurred" |
| 66 | + } |
| 67 | + ``` |
| 68 | + |
| 69 | +### PATCH - /answers/:answerId |
| 70 | + |
| 71 | +It will be used to update the answers. |
| 72 | + |
| 73 | +- **Params:** |
| 74 | + - None |
| 75 | +- **Query** |
| 76 | + - None |
| 77 | +- **Body** |
| 78 | + - **`status=[STRING]`** optional |
| 79 | +- **Headers** |
| 80 | + - n/a |
| 81 | +- **Cookie** |
| 82 | + - `rds-session` - for member or super user only |
| 83 | +- **Success Response:** |
| 84 | + - **Status Code:** 204 No content |
| 85 | + - **Content: n/a** |
| 86 | +- **Error Response:** |
| 87 | + - **Code:** 401 UNAUTHORIZED |
| 88 | + - **Content:** |
| 89 | + ```json |
| 90 | + { |
| 91 | + "statusCode": 401, |
| 92 | + "error": "Unauthorized", |
| 93 | + "message": "You are not authorized for this action." |
| 94 | + } |
| 95 | + ``` |
| 96 | + - **Code:** 500 INTERNAL_SERVER_ERROR |
| 97 | + - **Content:** |
| 98 | + ```json |
| 99 | + { |
| 100 | + "statusCode": 500, |
| 101 | + "error": "Internal Server Error", |
| 102 | + "message": "An internal server error occurred" |
| 103 | + } |
| 104 | + ``` |
| 105 | + |
| 106 | +<aside> |
| 107 | +📌 `reviewed_by` will be taken from `req.userData` in backend |
| 108 | +</aside> |
| 109 | + |
| 110 | +### GET - /answers |
| 111 | + |
| 112 | +It will be used to get all the answers in realtime. |
| 113 | + |
| 114 | +- **Params:** |
| 115 | + - None |
| 116 | +- **Query** |
| 117 | + - `status` - `<STRING>` |
| 118 | + - `eventId` - `<STRING>` |
| 119 | + - `questionId` - `<STRING>` |
| 120 | +- **Body** |
| 121 | + - none |
| 122 | +- **Headers** |
| 123 | + - Content-Type: 'text/event-stream' |
| 124 | + - Connection: 'keep-alive' |
| 125 | + - Cache-Control: 'no-cache' |
| 126 | +- **Cookie** |
| 127 | + - none |
| 128 | +- **Success Response:** |
| 129 | + - **Status Code:** 200 OK |
| 130 | + - **Content:** |
| 131 | + ```json |
| 132 | + { |
| 133 | + "message": "Answers returned successfully", |
| 134 | + "data": [ |
| 135 | + { |
| 136 | + "id": "<STRING>", |
| 137 | + "answer": "<STRING>", |
| 138 | + "status": "<STRING>", //(can be PENDING, APPROVED,REJECTED) //so that HOST | MODERATOR can filter out the answers which has to be shown in word cloud |
| 139 | + "reviewed_by": "<RDS_USER_ID> || null", //can be of HOST | MODERATOR |
| 140 | + "question_id": "<STRING>", //FOREIGN KEY POINTING TO QUESTION COLLECTION |
| 141 | + "answered_by": "<STRING>", //ID OF THE RESPONDER OF THE QUESTION(FROM PEERS COLLECTION) |
| 142 | + "event_id": "<STRING>", //ID OF THE EVENT IN WHICH ANSWER IS GIVEN |
| 143 | + "created_at": "TIMESTAMP", |
| 144 | + "updated_at": "TIMESTAMP" |
| 145 | + }, |
| 146 | + { |
| 147 | + "id": "<STRING>", |
| 148 | + "answer": "<STRING>", |
| 149 | + "status": "<STRING>", //(can be PENDING, APPROVED,REJECTED) //so that HOST | MODERATOR can filter out the answers which has to be shown in word cloud |
| 150 | + "reviewed_by": "<RDS_USER_ID> || null", //can be of HOST | MODERATOR |
| 151 | + "question_id": "<STRING>", //FOREIGN KEY POINTING TO QUESTION COLLECTION |
| 152 | + "answered_by": "<STRING>", //ID OF THE RESPONDER OF THE QUESTION(FROM PEERS COLLECTION) |
| 153 | + "event_id": "<STRING>", //ID OF THE EVENT IN WHICH ANSWER IS GIVEN |
| 154 | + "created_at": "TIMESTAMP", |
| 155 | + "updated_at": "TIMESTAMP" |
| 156 | + } |
| 157 | + ] |
| 158 | + } |
| 159 | + ``` |
| 160 | +- **Error Response:** |
| 161 | + - **Code:** 500 INTERNAL_SERVER_ERROR |
| 162 | + - **Content:** |
| 163 | + ```json |
| 164 | + { |
| 165 | + "statusCode": 500, |
| 166 | + "error": "Internal Server Error", |
| 167 | + "message": "An internal server error occurred" |
| 168 | + } |
| 169 | + ``` |
0 commit comments