Commit 18dd6b9a authored by thibaut-felten's avatar thibaut-felten

Doc

parent aff7b7a1
......@@ -28,13 +28,7 @@ class GameController extends Controller {
$data = json_decode(file_get_contents("php://input"),TRUE);
return $this->createGame($data);
break;
case 'PUT':
$id = $this->request->getURIParams()[0];
$data = json_decode(file_get_contents("php://input"),TRUE);
return $this->updateGame($id, $data);
break;
case 'DELETE':
$id = $this->request->getURIParams()[0];
return $this->deleteGame($id);
......@@ -65,26 +59,6 @@ class GameController extends Controller {
return $response;
}
public function updateGame($id, $data)
{
$gameValues = Game::getGame($id);
$gameValues=($gameValues[0]);
if($gameValues == []){
$response = Response::errorResponse("Game not found");
return $response;
}else{
if(array_key_exists('GAME_DESC',$data)){
$desc = $data['GAME_DESC'];
}else{
$desc = $gameValues->GAME_DESC;
}
$game = Game::updateGame(array(":GAME_ID" => $id, ":GAME_DESC" => $desc));
$response = new Response(200,json_encode($game));
return $response;
}
}
public function deleteGame($id)
{
$game = Game::getGame($id);
......
......@@ -34,4 +34,6 @@ cd path/to/uWamp/www/projet-cdaw/frontend
npm run serve
```
7. Se rendre sur le navigateur à l'adresse indiquée dans la console. [Normalement ici](http://localhost:8080/)
\ No newline at end of file
7. Se rendre sur le navigateur à l'adresse indiquée dans la console. [Normalement ici](http://localhost:8080/)
8. En cas d'erreur pour se connecter ou jouer, modifier la ligne 7 de [main.js](../frontend/src/main.js) avec le chemin vers le fichier [api.php](../backend/MVC/api.php)
\ No newline at end of file
# GET Game
Used to retrieve the information of one game
**URL** : `/api.php/game/{id}`
**Method** : `GET`
**Auth required** : NO
## Success Response
**Code** : `200 OK`
**Content example**
```json
{
"GAME_ID":"346",
"GAME_DESC":"Desc",
"GAME_PRIVATE":"0"
}
```
## Error Response
### No game at this id
**Code** : `400 Bad Request`
# POST Game
Used to create a game
**URL** : `/api.php/game/{id}`
**Method** : `POST`
**Auth required** : NO
**Data constraints**
```json
{
"GAME_DESC": "Description",
"GAME_PRIVATE": "0 if the game is public, 1 if private"
}
```
**Data example**
```json
{
"GAME_DESC": "testHTML",
"GAME_PRIVATE": "1"
}
```
## Success Response
**Code** : `200 OK`
## Error Response
### Errors in parameters
**Code** : `400 Bad Request`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment