Skip to content
Euen edited this page Sep 22, 2014 · 4 revisions
  1. Create
  2. Get status
  3. Get matches
  4. Play

Create

Create a new match by providing a player1 and player2.

A 400 status code will be returned in the following cases:

  • No players provided.
POST /matches

Input

Name Type Description
player2 string Required Unique. Name of the player two.

Headers:

content-type: application/json

Body:

{
    "player2":"Fede"
}

Response

Status: 200

Body:

{
    "id":390,
    "player1":"Juan",
    "player2":"Fede",
    "status":"on_course",
    "state": {
              "board": [[],[],[],[],[],[],[]],
              "next_player": 1
              },
    "created_at":"2014-9-12T15:47:20.000000Z",
    "updated_at":"2014-9-12T15:47:20.000000Z"
}

Get status

Retrieve the status of a match with the match_id.

A 400 status code will be returned in the following cases:

  • Match match_id doesn't exist.
GET /matches/:match_id

Input

Name Type Description
match_id integer Required. The Id of the Match.

GET /matches?match_id=3

Response

Status: 200

Body:

{
    "id":390,
    "player1":"Juan",
    "player2":"Fede",
    "status":"on_course",
    "state": {
              "board": [[],[],[],[],[],[],[]],
              "next_player": 1
              },
    "created_at":"2014-9-12T15:47:20.000000Z",
    "updated_at":"2014-9-12T15:47:20.000000Z"
}

Get matches

Retrieve the list of active matches of player.

A 204 status code will be returned in the following cases:

  • No match was found active.
GET /matches/

Response

Status: 200

Body:

[
 {
     "id":390,
     "player1":"Juan",
     "player2":"Fede",
     "status":"on_course",
     "state": {
               "board": [[],[],[],[],[],[],[]],
               "next_player": 1
               },
     "created_at":"2014-9-12T15:47:20.000000Z",
     "updated_at":"2014-9-12T15:47:20.000000Z"
 }
 {
     "id":391,
     "player1":"Aki",
     "player2":"Brujo",
     "status":"won",
     "state": {
               "board": [[],[],[],[],[],[],[]],
               "next_player": 1
               },
     "created_at":"2014-9-12T15:47:20.000000Z",
     "updated_at":"2014-9-12T15:47:20.000000Z"
 }
]

Play

Play in a existing match.

A 400 status code will be returned in the following cases:

  • Bad match_id provided.

A 404 status code will be returned in the following cases:

  • nonexistent match_id.
PUT /matches/:match_id

Input

Name Type Description
match_id integer Required. id of the match.
column integer Required. column in which he will play.

Headers:

content-type: application/json

Body:

{
    "column":7
}

Response

Status: 200

Body:

{
    "id":390,
    "player1":"Juan",
    "player2":"Fede",
    "status":"on_course",
    "state": {
              "board": [[],[],[],[],[],[],[1]],
              "next_player": 2
              },
    "created_at":"2014-9-12T15:47:20.000000Z",
    "updated_at":"2014-9-12T15:47:20.000000Z"
}
Clone this wiki locally