class SpiCardTransactionListToXs2aAccountReportMapper {

    public Optional<Xs2aCardAccountReport> mapToXs2aCardAccountReport(BookingStatus bookingStatus, List<SpiCardTransaction> spiCardTransactions, byte[] rawTransactionsResponse) {
        if (ArrayUtils.isNotEmpty(rawTransactionsResponse)) {
            return Optional.of(new Xs2aCardAccountReport(null, null, null, rawTransactionsResponse));
        }
        if (CollectionUtils.isEmpty(spiCardTransactions)) {
            return Optional.empty();
        }

        if (bookingStatus == BookingStatus.INFORMATION) {
            return Optional.of(new Xs2aCardAccountReport(null, null, toXs2aCardTransactionMapper.mapToXs2aCardTransactionList(spiCardTransactions), null));
        }

        List<CardTransaction> booked = Collections.emptyList();
        List<CardTransaction> pending = Collections.emptyList();


        if (bookingStatus != BookingStatus.PENDING) {
            booked = filterTransaction(spiCardTransactions, BOOKED_PREDICATE);
        }

        if (bookingStatus != BookingStatus.BOOKED) {
            pending = filterTransaction(spiCardTransactions, PENDING_PREDICATE);
        }

        return Optional.of(new Xs2aCardAccountReport(booked, pending, null, null));
    }

}