|
|
Når det postes til uri/api/highscore må bodyen være JSON på formen:
|
|
|
### GET uri/api/highscores/gamescore/:playerId/:gameId
|
|
|
|
|
|
Parameters:
|
|
|
* playerId (String, must be a valid MongoDB ID)
|
|
|
* gameId (String, must be a valid MongoDB ID)
|
|
|
|
|
|
Returns the highest score a user with playerId for game with gameId on the form:
|
|
|
```json
|
|
|
[
|
|
|
{
|
|
|
"_id": (String, valid MongoDB ID),
|
|
|
"gameId": (String, valid MongoDB ID),
|
|
|
"playerId": (String, valid MongoDB ID),
|
|
|
"value": Int
|
|
|
}
|
|
|
]
|
|
|
```
|
|
|
|
|
|
### POST uri/api/highscores/highscore
|
|
|
|
|
|
Posts the score if it is higher than the already existing one for the game and player. If the player has no exisiting score for said game a new one is created.
|
|
|
|
|
|
Body:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"userid": id [string],
|
|
|
"gameid": id [string],
|
|
|
"value": value [int],
|
|
|
} |
|
|
\ No newline at end of file |
|
|
"playerId": (String, valid MongoDB ID),
|
|
|
"gameId": (String, valid MongoDB ID),
|
|
|
"value": (Int),
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### GET uri/api/highscores/playerscore/:playerId
|
|
|
|
|
|
Parameters:
|
|
|
* playerId (String, must be a valid MongoDB ID)
|
|
|
|
|
|
Returns all the highscores a user has on the form:
|
|
|
```json
|
|
|
[
|
|
|
{
|
|
|
"_id": (String, valid MongoDB ID),
|
|
|
"gameId": (String, valid MongoDB ID),
|
|
|
"playerId": (String, valid MongoDB ID),
|
|
|
"value": Int
|
|
|
}
|
|
|
]
|
|
|
```
|
|
|
|
|
|
### GET uri/api/highscores/gamescores/:gameId
|
|
|
|
|
|
Parameters:
|
|
|
* gameId (String, must be a valid MongoDB ID)
|
|
|
|
|
|
Returns the five best highscores for the game with id = gameId sorted from high to low on the form:
|
|
|
```json
|
|
|
[
|
|
|
{
|
|
|
"_id": (String, valid MongoDB ID),
|
|
|
"gameId": (String, valid MongoDB ID),
|
|
|
"playerId": (String, valid MongoDB ID),
|
|
|
"value": Int
|
|
|
}
|
|
|
]
|
|
|
``` |
|
|
\ No newline at end of file |