package at.procon.eventhub.dto;

import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public record EventHubEventBatchDto(
        String packageKey,
        EventHubPackageRequest packageInfo,
        DataPackageType packageType,
        OffsetDateTime occurredFrom,
        OffsetDateTime occurredTo,
        List<EventHubEventDto> events,
        Map<String, Object> metadata
) {
    public EventHubEventBatchDto {
        events = events == null ? List.of() : List.copyOf(events);
        metadata = metadata == null ? Map.of() : Collections.unmodifiableMap(new LinkedHashMap<>(metadata));
    }
}
