class ScaApproachResolver {

    public ScaApproach resolveScaApproach() {
        List<ScaApproach> scaApproaches = aspspProfileService.getScaApproaches(requestProviderService.getInstanceId());
        ScaApproach firstScaApproach = getFirst(scaApproaches);
        Optional<Boolean> tppRedirectPreferredOptional = requestProviderService.resolveTppRedirectPreferred();
        if (tppRedirectPreferredOptional.isEmpty()) {
            return firstScaApproach;
        }

        boolean tppRedirectPreferred = tppRedirectPreferredOptional.get();
        if (tppRedirectPreferred && scaApproaches.contains(REDIRECT)) {
            return REDIRECT;
        }

        if (!tppRedirectPreferred
                && REDIRECT == firstScaApproach
                && scaApproaches.size() > 1) {
            return getSecond(scaApproaches);
        }

        return firstScaApproach;
    }

    public  ScaApproachResolver(Xs2aAuthorisationService xs2aAuthorisationService,
                               AspspProfileService aspspProfileService,
                               RequestProviderService requestProviderService);

}