class FactorServiceImpl implements FactorService {

    @Override
    public List<Factor> listEnrolledFactors(OktaUser user) throws OktaException
    {
        if (user != null)
        {
            String apiPath = String.format(OktaAPIConstants.LIST_ENROLLED_FACTORS, user.getId());
            ResponseEntity<Factor[]> exchange = oktaRestService.doRestCall(apiPath, HttpMethod.GET, Factor[].class, "parameters");
            if (!exchange.getStatusCode().is2xxSuccessful())
            {
                throw new OktaException(exchange.toString());
            }

            if (exchange.getBody().length > 0)
            {
                List<Factor> factors = Arrays.asList(exchange.getBody());
                factors.forEach(factor -> factor.setFactorSummary(buildFactorSummary(factor)));
                return factors;
            }
        }
        return Collections.emptyList();
    }

}