class SpiTransactionListToXs2aAccountReportMapper {

    public Optional<Xs2aAccountReport> mapToXs2aAccountReport(BookingStatus bookingStatus, List<SpiTransaction> spiTransactions, byte[] rawTransactionsResponse) {
        if (ArrayUtils.isNotEmpty(rawTransactionsResponse)) {
            return Optional.of(new Xs2aAccountReport(null, null, null, rawTransactionsResponse));
        }
        if (CollectionUtils.isEmpty(spiTransactions)) {
            return Optional.empty();
        }

        if (bookingStatus == BookingStatus.INFORMATION) {
            return Optional.of(new Xs2aAccountReport(null, null, toXs2aTransactionMapper.mapToXs2aTransactionList(spiTransactions), null));
        }

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


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

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

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

}