mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-12-31 21:56:41 +01:00
2.8 KiB
2.8 KiB
Friend
Available endpoints:
- POST
/users/:userId/friends - GET
/users/:userId/friends - GET
/users/:userId/friends/count - DELETE
/users/:userId/friends - DELETE
/users/:userId/friends/:friendId
Common return:
- 500 with response
{
"error": "Internal server error"
}
POST /users/:userId/friends/:friendId
Used to add a friend to an user
Can return:
- 200 with response
{
"msg": "Friend added successfully"
}
- 400 with response (if no user is specified in header, or friend is the user specified in header, or friend is already added)
{
"error": "<corresponding error>"
}
- 404 with response (if user does not exist, or friend does not exist)
{
"error": "<corresponding error>"
}
- 401 with response (if user specified in header is neither admin nor user)
{
"error": "<corresponding error>"
}
GET /users/:userId/friends?iStart=<starting index (included)>&iEnd=<ending index (excluded)>
Used to get the friends of an user
Can return:
- 200 with response (list of friend objects (between iStart and iEnd))
{
"friends":
[
{
"friendName": "<the friend's username>",
"friendDisplayName": "<the friend's display name>"
},
...
]
}
- 400 with response (if iStart/iEnd is missing, or iEnd < iStart)
{
"error": "<corresponding error>"
}
- 404 with response (if user does not exist, or no friends exist in the selected range)
{
"error": "<corresponding error>"
}
GET /users/:userId/friends/count
Used to get the number of friends of an user
Can return:
- 200 with response
{
"n_friends": <number of friends>
}
- 404 with response (if user does not exist)
{
"error": "<corresponding error>"
}
DELETE /users/:userId/friends
Used to delete the friends of an user
Can return:
- 200 with response
{
"msg": "Friends deleted successfully"
}
- 400 with response (if user specified in header is neither admin nor user)
{
"error": "<corresponding error>"
}
- 401 with response (if user specified in header is neither admin nor user)
{
"error": "<corresponding error>"
}
- 404 with response (if user does not exist)
{
"error": "<corresponding error>"
}
DELETE /users/:userId/friends/:friendId
Used to delete a friend of an user
Can return:
- 200 with response
{
"msg": "Friend deleted successfully"
}
- 400 with response (if user specified in header is neither admin nor user)
{
"error": "<corresponding error>"
}
- 401 with response (if user specified in header is neither admin nor user)
{
"error": "<corresponding error>"
}
- 404 with response (if user does not exist, or friend does not exist)
{
"error": "<corresponding error>"
}