Modification od Models, can now call APi without error in URL
continuous-integration/drone/push Build is passing Details

master
dorian.hodin 2 years ago
parent 332628d5b5
commit 16b932e47c

@ -55,10 +55,10 @@ class ModelAdmin
if (!empty($form)) { if (!empty($form)) {
$res = $this->client->request( $res = $this->client->request(
'POST', 'POST',
'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/addQuestion? 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/addQuestion?'.
content='.$questionContent.'& 'content='.$questionContent.'&'.
classQuestion='.get_class($question).'& 'classQuestion='.get_class($question).'&'.
idForm='.$form[0]['id'] 'idForm='.$form[0]['id']
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('AddQuestion failed'); throw new Exception('AddQuestion failed');
@ -88,9 +88,9 @@ class ModelAdmin
if (!validate::type($type)) { if (!validate::type($type)) {
throw new Exception('Type de question invalide'); throw new Exception('Type de question invalide');
} }
$res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteQuestion? $res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteQuestion?'.
classQuestion='.$type.'& 'classQuestion='.$type.'&'.
id='.$idQuestion 'id='.$idQuestion
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('DeleteQuestion failed'); throw new Exception('DeleteQuestion failed');
@ -118,10 +118,10 @@ class ModelAdmin
if(!validate::categories($categories)){ if(!validate::categories($categories)){
throw new Exception('Categories invalides'); throw new Exception('Categories invalides');
} }
$res = $this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertResponseInQuestion? $res = $this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertResponseInQuestion?'.
response='.$response.'& 'response='.$response.'&'.
categories='.json_encode($categories).'& 'categories='.json_encode($categories).'&'.
$idQuestion='.$idQuestion 'idQuestion='.$idQuestion
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('InsertResponseInQuestion failed'); throw new Exception('InsertResponseInQuestion failed');
@ -140,8 +140,8 @@ class ModelAdmin
public function deleteResponse(): void public function deleteResponse(): void
{ {
try { try {
$res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deletePossibleResponse? $res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deletePossibleResponse?'.
id='.$_POST["possibleResponse"] 'id='.$_POST["possibleResponse"]
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('DeletePossibleResponse failed'); throw new Exception('DeletePossibleResponse failed');
@ -167,9 +167,9 @@ class ModelAdmin
$formulaire = json_decode($res->getBody()); $formulaire = json_decode($res->getBody());
if (empty($formulaire)) { if (empty($formulaire)) {
$form = new Form(0, "Votre avis nous intéresse !!!", "Description de notre formulaire", array()); $form = new Form(0, "Votre avis nous intéresse !!!", "Description de notre formulaire", array());
$res = $this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertForm? $res = $this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertForm?'.
title='.$form->getTitle().'& 'title='.$form->getTitle().'&'.
description='.$form->getDescription() 'description='.$form->getDescription()
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('InsertForm failed'); throw new Exception('InsertForm failed');
@ -194,8 +194,8 @@ class ModelAdmin
if(!validate::keyword($keyword)){ if(!validate::keyword($keyword)){
throw new Exception('Mot-clef invalide'); throw new Exception('Mot-clef invalide');
} }
$res = $this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertKeyword? $res = $this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertKeyword?'.
keyword='.$keyword 'keyword='.$keyword
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('InsertKeyword failed'); throw new Exception('InsertKeyword failed');
@ -214,8 +214,8 @@ class ModelAdmin
public function deleteKeyword(): void public function deleteKeyword(): void
{ {
try { try {
$res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteKeyword? $res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteKeyword?'.
keyword='.$_POST["idCateg"] 'keyword='.$_POST["idCateg"]
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('DeleteKeyword failed'); throw new Exception('DeleteKeyword failed');
@ -270,9 +270,8 @@ class ModelAdmin
throw new Exception('GetForm failed'); throw new Exception('GetForm failed');
} }
$idForm = json_decode($res->getBody())[0]["id"]; $idForm = json_decode($res->getBody())[0]["id"];
$res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getAllQuestions? $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getAllQuestions?'.
idForm='.$idForm 'idForm='.$idForm);
);
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('GetAllQuestions failed'); throw new Exception('GetAllQuestions failed');
} }
@ -303,9 +302,8 @@ class ModelAdmin
$responsesCandidate = json_decode($res->getBody()); $responsesCandidate = json_decode($res->getBody());
$results = []; $results = [];
foreach ($responsesCandidate as $response) { foreach ($responsesCandidate as $response) {
$res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getDetailsListResponsesOfCandidate? $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getDetailsListResponsesOfCandidate?'.
id='.$response["id"] 'id='.$response["id"]);
);
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('GetDetailsListResponsesOfCandidate failed'); throw new Exception('GetDetailsListResponsesOfCandidate failed');
} }
@ -326,8 +324,8 @@ class ModelAdmin
public function deleteResponsesCandidate(): void public function deleteResponsesCandidate(): void
{ {
try { try {
$res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteListResponseOfCandidate? $res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteListResponseOfCandidate?'.
id='.Clean::int($_POST["idResponseCandidate"]) 'id='.Clean::int($_POST["idResponseCandidate"])
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('DeleteListResponseOfCandidate failed'); throw new Exception('DeleteListResponseOfCandidate failed');

@ -64,11 +64,11 @@ class ModelCandidate
} }
$form = json_decode($res->getBody()); $form = json_decode($res->getBody());
$title = $form[0]["title"]; $title = $form[0]["title"];
$res =$this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertListResponsesOfCandidate? $res =$this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertListResponsesOfCandidate?'.
id='.implode(",",$questionsId).'& 'id='.implode(",",$questionsId).'&'.
answer='.implode(",",$answer).'& 'answer='.implode(",",$answer).'&'.
category='.implode(",",$category).'& 'category='.implode(",",$category).'&'.
titleForm='.$title 'titleForm='.$title
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('InsertListResponsesOfCandidate failed'); throw new Exception('InsertListResponsesOfCandidate failed');
@ -101,7 +101,8 @@ class ModelCandidate
$title = $form[0]->title; $title = $form[0]->title;
$description = $form[0]->description; $description = $form[0]->description;
$res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getAllQuestions?idForm='.$form[0]->id $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getAllQuestions?'.
'idForm='.$form[0]->id
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('GetAllQuestion failed'); throw new Exception('GetAllQuestion failed');
@ -165,8 +166,8 @@ class ModelCandidate
$identifiant = Clean::simpleString($_REQUEST['login']); $identifiant = Clean::simpleString($_REQUEST['login']);
try { try {
if (Validate::login($identifiant) && Validate::password($password)) { if (Validate::login($identifiant) && Validate::password($password)) {
$res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getPasswordWithLogin? $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getPasswordWithLogin?'.
login='.$identifiant 'login='.$identifiant
); );
if ($res->getStatusCode()!=200){ if ($res->getStatusCode()!=200){
throw new Exception('GetPasswordWithLogin failed'); throw new Exception('GetPasswordWithLogin failed');

Loading…
Cancel
Save