class PiisConsentServiceInternal implements PiisConsentService {

    @Override
    @Transactional
    public CmsResponse<List<CmsConsent>> getPiisConsentListByAccountIdentifier(@Nullable Currency currency, AccountReferenceSelector accountReferenceSelector) {
        Specification<ConsentEntity> specification;

        specification = currency == null
                            ? piisConsentEntitySpecification.byAccountReferenceSelector(accountReferenceSelector)
                            : piisConsentEntitySpecification.byCurrencyAndAccountReferenceSelector(currency, accountReferenceSelector);

        List<CmsConsent> consents = consentJpaRepository.findAll(specification).stream()
            .map( piisConsentLazyMigrationService::migrateIfNeeded )
            .map( consentEntity -> cmsConsentMapper.mapToCmsConsent(consentEntity, Collections.emptyList(), Collections.emptyMap()) )
            .collect(Collectors.toList());

        return CmsResponse.<List<CmsConsent>>builder()
                   .payload(consents)
                   .build();
    }

}