Skip to content

Latest commit

 

History

History
111 lines (91 loc) · 2.47 KB

File metadata and controls

111 lines (91 loc) · 2.47 KB

minesweeper-API

Rest API for game of Minesweeper

Architectural approach

The solution follows Interaction-Driven Design (IDD), an iterative approach to software design and development based on Outside-In Development.

Tech stack

System requirements

In order to build and run the solution, you need to install:

  • JDK 1.8 (recommended installation via SDKMAN!)

Build

$ ./gradlew clean build

Create a User

POST /admin/users
{
    "userName": "diegap"
}

Response 201 CREATED

Create a Board (start game)

POST /users/:userName/boards

:userName string that defines the userName

{
    "rows": 4,
    "cols": 4,
    "mines": 1,
    "user": {
        "userName": "diegap"
    }
}

Response 201 CREATED

Response 404 NOT FOUND

If the userName does not exist an http status 404 is returned.

Retrieve boards (admin)

GET /admin/boards
{
    "boardIds": [
        "669a0b34-c8a8-4e30-b9da-7dd2a7d6e58f",
        "ccaead72-80ca-4517-bd1b-4a54b112cc75"
    ]
}

Response 200 OK

Pause/Resume a Board

PUT /users/:userName/boards/:boardId/status

:userName string that defines the userName

:boardId string that defines the boardId

{
    "status": "PAUSE"
}

Response 200 OK

Response 400 BAD REQUEST

The allowed values for status are "PAUSE" and "RESUME".

Actuate on Cell

PUT /users/:userName/boards/:boardId/cells

:userName string that defines the userName

:boardId string that defines the boardId

{
    "x": 0,
    "y": 2,
    "command": "REVEAL"
}

Response 200 OK

Response 400 BAD REQUEST

The allowed values for command are "REVEAL", "FLAG", "UNFLAG", "QUESTION" and "UNQUESTION".

Have in mind that a cell marked as "FLAG" or "QUESTION" cannot be revealed without being "UNFLAG" or "UNQUESTION" first.

DEMO

You can play with the latest deployed version at DEMO