Skip to content

Commit 0ef4fa8

Browse files
authored
add: contracts for questions and answers word cloud feature (#166)
1 parent f650371 commit 0ef4fa8

File tree

2 files changed

+272
-0
lines changed

2 files changed

+272
-0
lines changed

answers/README.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
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+
```

questions/README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# QUESTIONS - API CONTRACTS
2+
3+
| Method | Route | Description |
4+
| ------ | -------------------------------- | --------------------------------------------- |
5+
| POST | [/questions](#post---questions) | it will be used for host to ask the question. |
6+
| GET | [ /questions ](#get---questions) | it will be for users to get the question. |
7+
8+
### POST - /questions
9+
10+
It will be used for host to ask the question.
11+
12+
- **Params:**
13+
- None
14+
- **Query**
15+
- None
16+
- **Body**
17+
- **`question=[STRING]`** required - (The question text.)
18+
- **`createdBy=[STRING]`** required (The ID of the user who asked the question.)
19+
- **`eventId=[STRING]`** required (The ID of the session where the question was asked.)
20+
- **`maxCharacters=[NUMBER || null]`** optional
21+
- **Headers**
22+
- n/a
23+
- **Cookie**
24+
- `rds-session` - for super user or member
25+
- **Success Response:**
26+
27+
- **Status Code:** 201 CREATED
28+
- **Content:**
29+
30+
```json
31+
{
32+
"message": "Question created successfully",
33+
"data": {
34+
"id": "<STRING>",
35+
"question": "<STRING>",
36+
"created_by": "<STRING>",
37+
"event_id": "<STRING>",
38+
"max_characters": "<NUMBER>",
39+
"created_at": "TIMESTAMP"
40+
}
41+
}
42+
```
43+
44+
- **Error Response:**
45+
- **Code:** 401 UNAUTHORIZED
46+
- **Content:**
47+
```json
48+
{
49+
"statusCode": 401,
50+
"error": "Unauthorized",
51+
"message": "You are not authorized for this action."
52+
}
53+
```
54+
- **Code:** 500 INTERNAL_SERVER_ERROR
55+
- **Content:**
56+
```json
57+
{
58+
"statusCode": 500,
59+
"error": "Internal Server Error",
60+
"message": "An internal server error occurred"
61+
}
62+
```
63+
64+
### GET - /questions
65+
66+
It will be used to get the questions in realtime.
67+
68+
- **Params:**
69+
- None
70+
- **Query**
71+
- `eventId` - `<STRING>`
72+
- `questionId` - `<STRING>`
73+
- **Body**
74+
- `none`
75+
- **Headers**
76+
- Content-Type: 'text/event-stream'
77+
- Connection: 'keep-alive'
78+
- Cache-Control: 'no-cache'
79+
- **Cookie**
80+
- `none`
81+
- **Success Response:**
82+
- **Status Code:** 200 OK
83+
- **Content:**
84+
```json
85+
"data": {
86+
"id": "<STRING>",
87+
"question": "<STRING>",
88+
"event_id": "<STRING>",
89+
"max_characters": "<NUMBER>", //number of words answer can have for this question
90+
"created_at": "TIMESTAMP",
91+
"created_by": "STRING" //ID OF THE CREATOR OF THE QUESTION(FROM RDS USER COLLECTION)
92+
}
93+
```
94+
- **Error Response:**
95+
- **Code:** 500 INTERNAL_SERVER_ERROR
96+
- **Content:**
97+
```json
98+
{
99+
"statusCode": 500,
100+
"error": "Internal Server Error",
101+
"message": "An internal server error occurred"
102+
}
103+
```

0 commit comments

Comments
 (0)