Skip to content

Commit cef4dfe

Browse files
authored
DOC: Added an API contract for stocks/:userId (#203)
* added one doc for stocks api * typo fix * doc update fix wrt test cases
1 parent 829479e commit cef4dfe

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

stocks/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# STOCKS
2+
3+
| Method | Route | Description |
4+
| ------ | ----------------------------------------------- | -------------------------------------------------------------- |
5+
| GET | [/stocks/:userId](#get---stocks) | It will fetch you all the user stocks based on your own id. |
6+
7+
## Stocks Object
8+
```
9+
{
10+
"message": "User stocks returned successfully!",
11+
"userStocks": [
12+
{
13+
"id": string,
14+
"userId": string,
15+
"stockId": string,
16+
"stockName": string,
17+
"quantity": number,
18+
"orderValue": number,
19+
"initialStockValue": number
20+
}
21+
]
22+
}
23+
```
24+
25+
## **GET /stocks/:userId**
26+
27+
Returns all the stocks of the user.
28+
29+
- **Params**
30+
_Required:_ `userId=[string]`
31+
- **Query**
32+
None
33+
- **Body**
34+
None
35+
- **Headers**
36+
Content-Type: application/json
37+
- **Cookie**
38+
rds-session: `<JWT>`
39+
- **Success Response:**
40+
- **Code:** 200
41+
- **Content:**
42+
43+
```
44+
{
45+
"message": "User stocks returned successfully!",
46+
"userStocks": [
47+
{
48+
"id": string,
49+
"userId": string,
50+
"stockId": string,
51+
"stockName": string,
52+
"quantity": number,
53+
"orderValue": number,
54+
"initialStockValue": number
55+
}
56+
]
57+
}
58+
```
59+
60+
When No Stock is found.
61+
62+
- **Code:** 200
63+
- **Content:**
64+
65+
```
66+
{
67+
message: "No stocks found",
68+
userStocks: []
69+
}
70+
```
71+
72+
- **Error Response:**
73+
- **Code:** 403
74+
- **Content:**
75+
```
76+
{
77+
'statusCode': 403,
78+
'error': 'Unauthorized',
79+
'message': 'Unauthorized access'
80+
}
81+
```
82+
- **Code:** 500
83+
- **Content:**
84+
```
85+
{
86+
'statusCode': 500,
87+
'error': 'Internal Server Error',
88+
'message': 'An internal server error occurred'
89+
}
90+
```

0 commit comments

Comments
 (0)