class AssuranceServiceImpl implements AssuranceService {

    @Override
    public Response modify(String assuranceId, String orderId, int typeIndex, HttpHeaders headers) {
        Response oldAssuranceResponse = findAssuranceById(UUID.fromString(assuranceId), headers);
        Assurance oldAssurance = (Assurance) oldAssuranceResponse.getData();
        if (oldAssurance == null) {
            AssuranceServiceImpl.LOGGER.info("[Assurance-Modify-Service][ModifyAssurance] Fail.Assurance not found.");
            return new Response<>(0, "Fail.Assurance not found.", null);
        } else {
            AssuranceType at = AssuranceType.getTypeByIndex(typeIndex);
            if (at != null) {
                oldAssurance.setType(at);
                assuranceRepository.save(oldAssurance);
                AssuranceServiceImpl.LOGGER.info("[Assurance-Modify-Service][ModifyAssurance] Success.");
                return new Response<>(1, "Modify Success", oldAssurance);
            } else {
                AssuranceServiceImpl.LOGGER.info("[Assurance-Modify-Service][ModifyAssurance] Fail.Assurance Type not exist.");
                return new Response<>(0, "Assurance Type not exist", null);
            }
        }
    }

}