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) {