Skip to content

Commit

Permalink
DOC: Added an API contract for stocks/:userId (#203)
Browse files Browse the repository at this point in the history
* added one doc for stocks api

* typo fix

* doc update fix wrt test cases
  • Loading branch information
vikasosmium authored Dec 13, 2024
1 parent 829479e commit cef4dfe
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions stocks/README.md
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'
}
```

0 comments on commit cef4dfe

Please sign in to comment.