History Cards API¶
Get history¶
GET
- /history/get¶
Use this request to return a history list of cards the user have scanned.
Authorization
JWT Token inside request header, with key Authorization
and value Bearer <JWT-Token>
Query Parameter(s): none
Request Body: none
Success
The history can be returned.
Status Code: 200 OK
Response Body:
{ "_id": "<History Storage ID, not usable>", "userid": "<User ID of the history owner>", "list": [ { "_id": "<History item id, with time info>", "name": "<History user name>", "userid": "<Current item user id>", "profile": "<Profile avatar url>", "username": "<Current item user name>", "isFav": "<Is this user in the favourites of the request user>", }, ... ] }
Key | Type | Description |
---|---|---|
userid |
string |
User ID |
list |
List |
List of history items |
Bad Request
Status Code: 400 Bad Request
Response Body:
{ "error": "<Error message>" }
Unauthorized
Status Code: 401 Unauthorized
Response Body:
{ "error": "You are not authorized to access this resource" }
Add to history¶
POST
- /history/add¶
Use this request to add a single item into the user's history list. Any existing history of this particular id will be overwritten (i.e. only one history entry per each user, only newest entry is kept).
Authorization
JWT Token inside request header, with key Authorization
and value Bearer <JWT-Token>
Query Parameter(s): none
Request Body:
{ userid: string }
Key | Type | Description | Constraints | Default | Required |
---|---|---|---|---|---|
userid |
string |
MongoDb ObjectID of the history item (an viewed user) to add | MongoDb ObjectID Type | N/A | Yes |
Success
The history can be added.
Status Code: 200 OK
Response Body:
{ "success": "history updated" }
Key | Type | Description |
---|---|---|
success |
string |
success message |
Bad Request
Status Code: 400 Bad Request
Response Body:
{ "error": "<Error message>" }
Unauthorized
Status Code: 401 Unauthorized
Response Body:
{ "error": "You are not authorized to access this resource" }
Remove from history¶
POST
- /history/remove¶
Use this request to remove a single entry from the history.
Authorization
JWT Token inside request header, with key Authorization
and value Bearer <JWT-Token>
Query Parameter(s): none
Request Body:
{ userid: string }
Key | Type | Description | Constraints | Default | Required |
---|---|---|---|---|---|
userid |
string |
MongoDb ObjectID of the history item (an viewed user) to remove | MongoDb ObjectID Type | N/A | Yes |
Success
The history is removed if the userid provided is correct.
Status Code: 200 OK
Response Body:
{ "success": "history might be removed" }
Key | Type | Description |
---|---|---|
success |
string |
success message |
Bad Request
Status Code: 400 Bad Request
Response Body:
{ "error": "<Error message>" }
Unauthorized
Status Code: 401 Unauthorized
Response Body:
{ "error": "You are not authorized to access this resource" }
POST
- /history/remove-all¶
Use this request to remove all entries from the history list.
Authorization
JWT Token inside request header, with key Authorization
and value Bearer <JWT-Token>
Query Parameter(s): none
Request Body: none
Success
The history is cleared.
Status Code: 200 OK
Response Body:
{ "success": "history is cleared" }
Key | Type | Description |
---|---|---|
success |
string |
success message |
Bad Request
Status Code: 400 Bad Request
Response Body:
{ "error": "<Error message>" }
Unauthorized
Status Code: 401 Unauthorized
Response Body:
{ "error": "You are not authorized to access this resource" }