class AdditionalInformationSupportedService {

    public CreateConsentReq checkIfAdditionalInformationSupported(CreateConsentReq request) {
        boolean isOwnerNameSupported = aspspProfileService.isAccountOwnerInformationSupported();
        boolean isTrustedBeneficiariesSupported = aspspProfileService.isTrustedBeneficiariesSupported();

        if (!isOwnerNameSupported) {
            clearAccountAccessType(request);
        }

        if (!isOwnerNameSupported || !isTrustedBeneficiariesSupported) {
            AccountAccess access = request.getAccess();
            AdditionalInformationAccess additionalInformationAccess = access.getAdditionalInformationAccess();
            if (additionalInformationAccess != null) {
                AdditionalInformationAccess additionalInformationCleaned = new AdditionalInformationAccess(
                    isOwnerNameSupported ? additionalInformationAccess.getOwnerName() : null,
                    isTrustedBeneficiariesSupported ? additionalInformationAccess.getTrustedBeneficiaries() : null);
                request.setAccess(new AccountAccess(access.getAccounts(),
                                                    access.getBalances(),
                                                    access.getTransactions(),
                                                    additionalInformationCleaned));
            }
        }

        return request;
    }

}