Commit 9c8e90ac authored by Robin Borgogno's avatar Robin Borgogno

doc api

parent 904c942d
......@@ -65,14 +65,14 @@ class GameuserController extends Controller {
public function addUserGame($data)
{
$idLigne = Game::addUserGame(array(":GAME_ID" => $data['GAME_ID'], ":USER_ID" => $data['USER_ID']));
$response = new Response(200,json_encode("Joueur ajouté"));
$response = new Response(200,json_encode("User added"));
return $response;
}
public function deleteUserGame($data)
{
$game = Game::deleteUserGame(array(":GAME_ID" => $data['GAME_ID'], ':USER_ID' => $data['USER_ID']));
$response = new Response(200, json_encode("Ligne supprimé"));
$response = new Response(200, json_encode("Deleted"));
return $response;
}
......
......@@ -51,14 +51,14 @@ class OnlineController extends Controller {
public function addUserOnline($id)
{
Online::addUserOnline(array(":id" => $id));
return Response::okresponse(json_encode("It's ok bro"));
return Response::okresponse(json_encode("Online user added"));
}
public function deleteUserOnline($id,$data)
{
Online::deleteUserOnline(array(":id" => $id));
Game::deleteUserGame(array(":GAME_ID" => $data['GAME_ID'], ':USER_ID' => $id));
return Response::okresponse(json_encode("It's ok bro for delete"));
return Response::okresponse(json_encode("Online user deleted"));
}
}
......@@ -44,7 +44,7 @@ class ResultController extends Controller {
public function saveAwnser($id, $data)
{
Result::saveAwnser(array(":id" => $id, ":user_id" => $data['USER_ID'], ":awn" => $data['value']));
return Response::okresponse(json_encode("Tout va bien"));
return Response::okresponse(json_encode("Result Added"));
}
public function returnResultGameID($id)
......@@ -55,7 +55,13 @@ class ResultController extends Controller {
public function deleteLine($data)
{
$res = Result::getLigneByUserID(array(":id" => $data['USER_ID']));
if($res == array()){
return Response::errorInParametersResponse("Result not found");
}else {
Result::deleteLigne(array(":id" => $data['USER_ID']));
return Response::okresponse(json_encode("Theo"));
return Response::okresponse(json_encode("Result deleted"));
}
}
}
......@@ -24,4 +24,10 @@ class Result extends Model {
return;
}
public static function getLigneByUserID($values)
{
$stm = parent::exec('GET_BY_USERID',$values);
return $stm->fetchAll();
}
}
\ No newline at end of file
......@@ -8,3 +8,6 @@ Result::addSqlQuery('RESULT_GET',
Result::addSqlQuery('RESULT_DELETE',
"DELETE FROM RESULT WHERE RESULT.USER_ID = :id");
Result::addSqlQuery('GET_BY_USERID',
"SELECT * FROM RESULT WHERE RESULT.USER_ID = :id");
\ No newline at end of file
# DELETE Gameuser
Used to delete a user in a game.
**URL** : `/api.php/gameuser`
**Method** : `DELETE`
**Auth required** : NOT FOR THE MOMENT BUT WORKING ON IT
**Data constraints**
```json
{
"USER_ID":"[id which does exicts]",
"GAME_ID" : "[id which does exicts]"
}
```
**Data example**
```json
{
"USER_ID": "4",
"GAME_ID": "67"
}
```
## Success Response
**Code** : `200 OK`
**Content example**
`"Deleted"`
\ No newline at end of file
# DELETE Online
Used to delete a online user.
**URL** : `/api.php/online/{user.id}`
**Method** : `DELETE`
**Auth required** : NOT FOR THE MOMENT BUT WORKING ON IT
## Success Response
**Code** : `200 OK`
**Content example**
`"Online user deleted"`
\ No newline at end of file
# DELETE Result
Used to delete a round result.
**URL** : `/api.php/result`
**Method** : `DELETE`
**Auth required** : NOT FOR THE MOMENT BUT WORKING ON IT
**Data constraints**
```json
{
"USER_ID":"[login which does exicts]",
}
```
**Data example**
```json
{
"USER_ID": "4"
}
```
## Success Response
**Code** : `200 OK`
**Content example**
`"Result deleted"`
## Error Response
### Mauvais id
**Code** : `400 Bad Request`
**Content example**
`"Result not found"`
\ No newline at end of file
# GET User
Used to retrieve all users in one game
**URL** : `/api.php/gameuser/game/{game.id}`
**Method** : `GET`
**Auth required** : NO
## Success Response
**Code** : `200 OK`
**Content example**
```json
[{
"GAME_HISTO_ID" : "2",
"GAME_ID" : "64",
"USER_ID" : "12"
},
{
"GAME_HISTO_ID" : "3",
"GAME_ID" : "64",
"USER_ID" : "13"
}]
```
# GET User
Used to retrieve the information of all games for one user
**URL** : `/api.php/gameuser/user/{user.id}`
**Method** : `GET`
**Auth required** : NO
## Success Response
**Code** : `200 OK`
**Content example**
```json
{
"GAME_ID" : "64",
"GAME_DESC" : "Description",
"GAME_PRIVATE" : "1"
}
```
# GET Online
RETURN GAME ID FOR THE USER OR NOTHING IN CASE OF NO ASSIGMENT
**URL** : `/api.php/online/{user.id}`
**Method** : `GET`
**Auth required** : NOT FOR THE MOMENT BUT WORKING ON IT
## Success Response
**Code** : `200 OK`
**Content example**
```json
{
"54"
}
```
## OR
```json
{
}
```
\ No newline at end of file
# GET Result
Used to delete a round result.
**URL** : `/api.php/result/{game.id}`
**Method** : `GET`
**Auth required** : NOT FOR THE MOMENT BUT WORKING ON IT
## Success Response
**Code** : `200 OK`
**Content example**
```json
{
"RESULT_ID": "1",
"USER_ID": "1",
"GAME_ID" : "54",
"RESULT_AWNSER" : "rock"
}
```
\ No newline at end of file
# POST Gameuser
Used to add a user in a gme.
**URL** : `/api.php/gameuser`
**Method** : `POST`
**Auth required** : NOT FOR THE MOMENT BUT WORKING ON IT
**Data constraints**
```json
{
"USER_ID":"[id which does exicts]",
"GAME_ID" : "[id which does exicts]"
}
```
**Data example**
```json
{
"USER_ID": "4",
"GAME_ID": "67"
}
```
## Success Response
**Code** : `200 OK`
**Content example**
`"User Added"`
\ No newline at end of file
# POST Online
Used to add a online user.
**URL** : `/api.php/online/{user.id}`
**Method** : `POST`
**Auth required** : NOT FOR THE MOMENT BUT WORKING ON IT
## Success Response
**Code** : `200 OK`
**Content example**
`"Online user Added"`
\ No newline at end of file
# DELETE Result
Used to add a round result.
**URL** : `/api.php/result/{game.id}`
**Method** : `POST`
**Auth required** : NOT FOR THE MOMENT BUT WORKING ON IT
**Data constraints**
```json
{
"USER_ID":"[id which does exicts]",
"value" : "[must be : 'paper', 'rocks' or 'scissor']"
}
```
**Data example**
```json
{
"USER_ID": "4",
"value": "paper"
}
```
## Success Response
**Code** : `200 OK`
**Content example**
`"Result Added"`
\ No newline at end of file
......@@ -4,7 +4,7 @@ import router from './router'
Vue.config.productionTip = false
sessionStorage.setItem('APIURL', 'http://localhost/projet-cdaw/backend/MVC/api.php')
sessionStorage.setItem('APIURL', 'http://localhost/felten/projet-cdaw/backend/MVC/api.php')
new Vue({
router,
......
......@@ -48,8 +48,8 @@ export default {
components: {
LoginNavbar
},
data(){ // the data, declared as function
return{ // we return all the properties that should be react on.
data(){
return{
user
}
},
......
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