Difference between revisions of "W3911 Sudoku Server"

From Coder Merlin
(Added JSON decoding)
Line 9: Line 9:


End Points
End Points
* POST /games?difficulty=<difficulty>
{{RestAPI
    * Action: Creates a new game and associated board
|endpoint=POST /games?difficulty=<difficulty>
    * Parameters:
|action=Creates a new game and associated board
      * difficulty: easy|medium|hard|hell
|parameters=difficulty: easy {{Bar}} medium {{Bar}} hard {{Bar}} hell
    * Payload: None
|body=<span style="font-style: italic;">none</span>
     * Response: Id uniquely identifying a game
|statusCode=201 Created
    * Status code: 201 Created
|response=ID (integer) of newly created game
* GET /games/<id>/cells
     {"id":<id>}
    * Action: None
|responseExample={"id": 728134}
    * Payload: None
}}
     * Response: cells
{{RestAPI
    * Status code: 200 OK
|endpoint=GET /games/<id>/cells
|action=Returns the current cells for the specified game
|parameters=<span style="font-style: italic;">none</span>
|body=<span style="font-style: italic;">none</span>
|statusCode=200 OK
|response=Cells
     {"id":<id>}
|responseExample={"id": 728134}
}}
 
* PUT /games/<id>/cells/<boxIndex>/<cellIndex>
* PUT /games/<id>/cells/<boxIndex>/<cellIndex>
     * Action: Place specified value at in game at boxIndex, cellIndex
     * Action: Place specified value at in game at boxIndex, cellIndex

Revision as of 07:42, 7 October 2021

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Background A Sudoku board is made up of nine boxes. Boxes (container for nine cells) are listed from top-to-bottom, left-to-right indexed from zero. Cells are listed from top-to-bottom, left-to-right, indexed from zero. All valid payloads and responses must use well-formed JSON. “cells” is returned as follows: “cells”: [[<nine values from top-left>], [<nine values from top-middle>], …]

End Points


POST /games?difficulty=<difficulty>
Creates a new game and associated board
   Parameters: 
   difficulty: easy | medium | hard | hell
   Body: none
   Status code: 201 Created
   Response: ID (integer) of newly created game
   {"id":<id>}
   
{"id": 728134}
   Errors:
   
{{{errors}}}



GET /games/<id>/cells
Returns the current cells for the specified game
   Parameters: 
   none
   Body: none
   Status code: 200 OK
   Response: Cells
   {"id":<id>}
   
{"id": 728134}
   Errors:
   
{{{errors}}}


  • PUT /games/<id>/cells/<boxIndex>/<cellIndex>
   * Action: Place specified value at in game at boxIndex, cellIndex
   * Payload: value (null for removing value)
   * Response: Nothing
   * Status: 204 No Content

JSON Encoding[edit]

CoderMerlin™ Code Explorer: W0000 (1) 🟢

JSON Decoding[edit]

CoderMerlin™ Code Explorer: W0000 (2) 🟢

Issue Request from Client to Server[edit]

CoderMerlin™ Code Explorer: W0000 (3) 🟢