Added endpoint
DELETE /api/v1/summits/{id}/rsvp-templates/{template_id}/questions/{question_id} Change-Id: Ifb42b15c9879d53dc845af580381a04f2ae3e03d
This commit is contained in:
parent
8b8e08e051
commit
3b92c8470a
@ -27,6 +27,7 @@ use utils\Filter;
|
|||||||
use utils\FilterParser;
|
use utils\FilterParser;
|
||||||
use utils\OrderParser;
|
use utils\OrderParser;
|
||||||
use utils\PagingInfo;
|
use utils\PagingInfo;
|
||||||
|
use Exception;
|
||||||
/**
|
/**
|
||||||
* Class OAuth2SummitRSVPTemplatesApiController
|
* Class OAuth2SummitRSVPTemplatesApiController
|
||||||
* @package App\Http\Controllers
|
* @package App\Http\Controllers
|
||||||
@ -364,4 +365,35 @@ final class OAuth2SummitRSVPTemplatesApiController extends OAuth2ProtectedContro
|
|||||||
return $this->error500($ex);
|
return $this->error500($ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $summit_id
|
||||||
|
* @param $template_id
|
||||||
|
* @param $question_id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function deleteRSVPTemplateQuestion($summit_id, $template_id, $question_id){
|
||||||
|
try {
|
||||||
|
|
||||||
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||||
|
if (is_null($summit)) return $this->error404();
|
||||||
|
|
||||||
|
$this->rsvp_template_service->deleteQuestion($summit, $template_id, $question_id);
|
||||||
|
|
||||||
|
return $this->deleted();
|
||||||
|
}
|
||||||
|
catch (ValidationException $ex1) {
|
||||||
|
Log::warning($ex1);
|
||||||
|
return $this->error412(array($ex1->getMessage()));
|
||||||
|
}
|
||||||
|
catch(EntityNotFoundException $ex2)
|
||||||
|
{
|
||||||
|
Log::warning($ex2);
|
||||||
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
||||||
|
}
|
||||||
|
catch (Exception $ex) {
|
||||||
|
Log::error($ex);
|
||||||
|
return $this->error500($ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -175,6 +175,14 @@ Route::group([
|
|||||||
Route::group(['prefix' => '{question_id}'], function () {
|
Route::group(['prefix' => '{question_id}'], function () {
|
||||||
Route::put('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@updateRSVPTemplateQuestion']);
|
Route::put('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@updateRSVPTemplateQuestion']);
|
||||||
Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@getRSVPTemplateQuestion']);
|
Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@getRSVPTemplateQuestion']);
|
||||||
|
Route::delete('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@deleteRSVPTemplateQuestion']);
|
||||||
|
// multi values questions
|
||||||
|
Route::group(['prefix' => 'values'], function () {
|
||||||
|
|
||||||
|
Route::group(['prefix' => '{value_id}'], function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -51,4 +51,14 @@ interface IRSVPTemplateService
|
|||||||
*/
|
*/
|
||||||
public function updateQuestion(Summit $summit, $template_id, $question_id, array $payload);
|
public function updateQuestion(Summit $summit, $template_id, $question_id, array $payload);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Summit $summit
|
||||||
|
* @param int $template_id
|
||||||
|
* @param int $question_id
|
||||||
|
* @return void
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function deleteQuestion(Summit $summit, $template_id, $question_id);
|
||||||
|
|
||||||
}
|
}
|
@ -45,7 +45,6 @@ final class RSVPTemplateService implements IRSVPTemplateService
|
|||||||
$this->tx_service = $tx_service;
|
$this->tx_service = $tx_service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Summit $summit
|
* @param Summit $summit
|
||||||
* @param int $template_id
|
* @param int $template_id
|
||||||
@ -188,4 +187,50 @@ final class RSVPTemplateService implements IRSVPTemplateService
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Summit $summit
|
||||||
|
* @param int $template_id
|
||||||
|
* @param int $question_id
|
||||||
|
* @return void
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function deleteQuestion(Summit $summit, $template_id, $question_id)
|
||||||
|
{
|
||||||
|
return $this->tx_service->transaction(function() use($summit, $template_id, $question_id){
|
||||||
|
|
||||||
|
$template = $summit->getRSVPTemplateById($template_id);
|
||||||
|
|
||||||
|
if(is_null($template))
|
||||||
|
throw new EntityNotFoundException
|
||||||
|
(
|
||||||
|
trans
|
||||||
|
(
|
||||||
|
'not_found_errors.RSVPTemplateService.deleteQuestion.TemplateNotFound',
|
||||||
|
[
|
||||||
|
'summit_id' => $summit->getId(),
|
||||||
|
'template_id' => $template_id,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$question = $template->getQuestionById($question_id);
|
||||||
|
if(is_null($question))
|
||||||
|
throw new EntityNotFoundException
|
||||||
|
(
|
||||||
|
trans
|
||||||
|
(
|
||||||
|
'not_found_errors.RSVPTemplateService.deleteQuestion.QuestionNotFound',
|
||||||
|
[
|
||||||
|
'summit_id' => $summit->getId(),
|
||||||
|
'template_id' => $template_id,
|
||||||
|
'question_id' => $question_id,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->removeQuestion($question);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -46,4 +46,6 @@ return [
|
|||||||
'RSVPTemplateService.addQuestion.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
'RSVPTemplateService.addQuestion.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
||||||
'RSVPTemplateService.updateQuestion.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
'RSVPTemplateService.updateQuestion.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
||||||
'RSVPTemplateService.updateQuestion.QuestionNotFound' => 'question :question_id not found on template :template_id',
|
'RSVPTemplateService.updateQuestion.QuestionNotFound' => 'question :question_id not found on template :template_id',
|
||||||
|
'RSVPTemplateService.deleteQuestion.TemplateNotFound' => 'template :template_id not found on summit :summit_id',
|
||||||
|
'RSVPTemplateService.deleteQuestion.QuestionNotFound' => 'question :question_id not found on template :template_id',
|
||||||
];
|
];
|
@ -242,4 +242,31 @@ final class OAuth2SummitRSVPTemplateApiTest extends ProtectedApiTest
|
|||||||
$this->assertTrue(!is_null($question));
|
$this->assertTrue(!is_null($question));
|
||||||
return $question;
|
return $question;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDeleteRSVPTemplateQuestion($summit_id = 24, $template_id = 13, $question_id = 85){
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'id' => $summit_id,
|
||||||
|
'template_id' => $template_id,
|
||||||
|
'question_id' => $question_id
|
||||||
|
];
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||||
|
"CONTENT_TYPE" => "application/json"
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->action(
|
||||||
|
"DELETE",
|
||||||
|
"OAuth2SummitRSVPTemplatesApiController@deleteRSVPTemplateQuestion",
|
||||||
|
$params,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
$headers
|
||||||
|
);
|
||||||
|
|
||||||
|
$content = $response->getContent();
|
||||||
|
$this->assertResponseStatus(204);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user