generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOC: Added an API contract for stocks/:userId (#203)
* added one doc for stocks api * typo fix * doc update fix wrt test cases
- Loading branch information
1 parent
829479e
commit cef4dfe
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,90 @@ | ||
# STOCKS | ||
|
||
| Method | Route | Description | | ||
| ------ | ----------------------------------------------- | -------------------------------------------------------------- | | ||
| GET | [/stocks/:userId](#get---stocks) | It will fetch you all the user stocks based on your own id. | | ||
|
||
## Stocks Object | ||
``` | ||
{ | ||
"message": "User stocks returned successfully!", | ||
"userStocks": [ | ||
{ | ||
"id": string, | ||
"userId": string, | ||
"stockId": string, | ||
"stockName": string, | ||
"quantity": number, | ||
"orderValue": number, | ||
"initialStockValue": number | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## **GET /stocks/:userId** | ||
|
||
Returns all the stocks of the user. | ||
|
||
- **Params** | ||
_Required:_ `userId=[string]` | ||
- **Query** | ||
None | ||
- **Body** | ||
None | ||
- **Headers** | ||
Content-Type: application/json | ||
- **Cookie** | ||
rds-session: `<JWT>` | ||
- **Success Response:** | ||
- **Code:** 200 | ||
- **Content:** | ||
|
||
``` | ||
{ | ||
"message": "User stocks returned successfully!", | ||
"userStocks": [ | ||
{ | ||
"id": string, | ||
"userId": string, | ||
"stockId": string, | ||
"stockName": string, | ||
"quantity": number, | ||
"orderValue": number, | ||
"initialStockValue": number | ||
} | ||
] | ||
} | ||
``` | ||
When No Stock is found. | ||
- **Code:** 200 | ||
- **Content:** | ||
``` | ||
{ | ||
message: "No stocks found", | ||
userStocks: [] | ||
} | ||
``` | ||
- **Error Response:** | ||
- **Code:** 403 | ||
- **Content:** | ||
``` | ||
{ | ||
'statusCode': 403, | ||
'error': 'Unauthorized', | ||
'message': 'Unauthorized access' | ||
} | ||
``` | ||
- **Code:** 500 | ||
- **Content:** | ||
``` | ||
{ | ||
'statusCode': 500, | ||
'error': 'Internal Server Error', | ||
'message': 'An internal server error occurred' | ||
} | ||
``` |