package at.procon.eventhub.processing.dto;

import at.procon.eventhub.processing.model.UnifiedEventSourceFamily;
import at.procon.eventhub.processing.model.UnifiedRuntimeEventBackend;
import at.procon.eventhub.processing.model.UnifiedRuntimeProcessingRequest;
import java.time.OffsetDateTime;
import java.util.Set;
import java.util.UUID;

public record UnifiedRuntimeProcessingApiRequest(
        UUID sessionId,
        String tenantKey,
        Set<UnifiedEventSourceFamily> sourceFamilies,
        UnifiedRuntimeEventBackend eventBackend,
        String driverKey,
        String driverSourceEntityId,
        String driverCardNation,
        String driverCardNumber,
        OffsetDateTime occurredFrom,
        OffsetDateTime occurredTo,
        Boolean expandVehicleEvents,
        Integer vehicleExpansionPaddingMinutes
) {
    public UnifiedRuntimeProcessingRequest toRuntimeRequest() {
        return new UnifiedRuntimeProcessingRequest(
                sessionId,
                tenantKey,
                sourceFamilies,
                eventBackend,
                driverKey,
                driverSourceEntityId,
                driverCardNation,
                driverCardNumber,
                occurredFrom,
                occurredTo,
                expandVehicleEvents == null || expandVehicleEvents,
                vehicleExpansionPaddingMinutes == null ? 0 : Math.max(0, vehicleExpansionPaddingMinutes)
        );
    }
}
