From b5e015a6fe6e355305a3993716e309055cea0383 Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Wed, 15 Aug 2018 03:30:23 -0600 Subject: [PATCH] [mod] Del method for employee --- api-payroll/src/application/EmployeeApplication.php | 9 ++++++++- api-payroll/src/routes.php | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/api-payroll/src/application/EmployeeApplication.php b/api-payroll/src/application/EmployeeApplication.php index 1deb41d..8452256 100644 --- a/api-payroll/src/application/EmployeeApplication.php +++ b/api-payroll/src/application/EmployeeApplication.php @@ -504,7 +504,14 @@ class EmployeeApplication{ return $response; } - function disableEmployeeRecord($idEmployee){ + /** + * @param $code string + * @throws Exception + */ + function disableEmployeeRecord($code){ + $this->asserts->isNotEmpty($code, "The code can't be empty."); + + $idEmployee = $this->getIdEmployeeByCode($code); $this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0"); try { diff --git a/api-payroll/src/routes.php b/api-payroll/src/routes.php index ee0cd6f..2925699 100644 --- a/api-payroll/src/routes.php +++ b/api-payroll/src/routes.php @@ -65,12 +65,12 @@ $app->put('/api/employee', function ($request, $response) { ->write(json_encode($this->employeeApplication->updateEmployeeData($requestData))); }); -$app->DELETE('/api/employee/{idEmployee}', function (Request $request, Response $response, array $args) { - $idEmployee = $args['idEmployee']; +$app->DELETE('/api/employee/{code}', function (Request $request, Response $response, array $args) { + $code = $args['code']; return $response->withStatus(200) ->withHeader('Content-Type', 'application/json') - ->write(json_encode($this->employeeApplication->disableEmployeeRecord($idEmployee))); + ->write(json_encode($this->employeeApplication->disableEmployeeRecord($code))); }); $app->get('/api/employee/type/{code}', function (Request $request, Response $response, array $args) {