package at.procon.eventhub.processing.dto;

import at.procon.eventhub.processing.driverworkingtime.model.DriverWorkingTimeVehicleUsageInterval;
import at.procon.eventhub.tachographfilesession.model.ResolvedVehicleUsageInterval;
import java.time.OffsetDateTime;

public record RuntimeVehicleUsageIntervalDebugDto(
        String intervalId,
        OffsetDateTime from,
        OffsetDateTime to,
        String registrationKey,
        String vehicleKey,
        String sourceKind
) {
    public static RuntimeVehicleUsageIntervalDebugDto from(ResolvedVehicleUsageInterval interval) {
        if (interval == null) {
            return null;
        }
        return new RuntimeVehicleUsageIntervalDebugDto(
                interval.intervalId(),
                interval.from(),
                interval.to(),
                interval.registrationKey(),
                interval.vehicleKey(),
                interval.sourceKind()
        );
    }

    public static RuntimeVehicleUsageIntervalDebugDto from(DriverWorkingTimeVehicleUsageInterval interval) {
        if (interval == null) {
            return null;
        }
        return new RuntimeVehicleUsageIntervalDebugDto(
                interval.intervalId(),
                interval.startedAt(),
                interval.endedAt(),
                interval.registrationKey(),
                interval.vehicleKey(),
                interval.sourceKind()
        );
    }
}
