Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 1.43 KB

RESTful-API.md

File metadata and controls

31 lines (25 loc) · 1.43 KB

RESTful API

Expected Workflows

First time player

  1. Create a player (POST /players)
  2. Start a session (POST /sessions) to get a token. Tokens are short lived. You have to repeat this step each time the token is invalidated.

Human vs Human match

  1. Check the list of players (GET /players)
  2. Start a match against one (POST /matches)
  3. Check the match status to see if it's your turn (GET /matches/:match_id)
  4. When it's your turn, play (PATCH /matches/:match_id)
  5. Repeat from 3 until the response from 3 or 4 indicates the game is over

Human vs AI match

  1. Check the list of AI players (GET /ai-players)
  2. Start a match against one (POST /matches).
  3. Check the response from 2, it's your turn now
  4. Play (PATCH /matches/:match_id)
  5. If you haven't won yet, check the match status (GET /matches/:match_id)
  6. If you haven't lost yet, repeat from 4

Voluntarily invalidating a session

  1. Delete the session (DELETE /sessions/:session_token)

Cancelling a Match

  1. Delete the match (DELETE /matches/:match_id)

Boot up the server and check the API's Swagger Page