Skip to content

rest service api

detsam edited this page Nov 30, 2012 · 14 revisions

RESTful Stat Service API

Commands

Creating new game match

URI http://{host:port/{context_name}}/game/{gameId}/match
Method PUT
Path variables gameId Game hub UUID unique for every hub.
Request Body multipart/form-data
Form accountName User account name string.
Returns
200 OK
Content-type JSON (application/json)
matchId Created match UUID
401 Unauthorized In case where accountName invalid, inactive, etc.
404 Not Found

Game match ending

URI http://{host:port/{context_name}}/game/{gameId}/match/{matchId}/result
Method POST
Path variables
gameId Game hub UUID unique for every hub.
matchId Game match UUID unique for every match.
Request Body multipart/form-data
Form
accountName User account name, not empty string.
ricoshetsCount Ball ricoshets count, must be a positive or zero integer.
winnerName Match winner name, must be a not empty string.
maxBallSpeed Ball max speed in game, must be a positive integer.
Returns 200 OK & empty body
401 Unauthorized In case where accountName invalid, inactive, etc.
404 Not Found

Queries

Account statistic query

URI http://{host:port/{context_name}}/statistic/{accountName}
Method GET
Path variables
accountName Account name for statistic query.
Returns
200 OK
Content-type JSON (application/json)
playerReport Player Report Type
401 Unauthorized In case where accountName invalid, inactive, etc.
404 Not Found

An example of using the API ( Create, End and Get Statistic )

1 Step: PUT /game/15432/match accountName=PingPongGod

First, we create a new game match on the 15432 hub, parse the response and take matchId af1234ba.

2 Step: POST /game/15432/match/af1234ba/result accountName=PingPongGod&winner=PingPongGod&[etc.]

After match ends we POST result of the match by match id and hub id.

3 Step: GET /statistic/PingPongGod

After all we can fetch account statistic by account name.