package at.procon.eventhub.esperpoc.dto;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.OffsetDateTime;
import java.util.UUID;

public record EsperPocRequest(
        @NotBlank String tenantKey,
        @NotNull UUID driverEntityId,
        @NotNull OffsetDateTime occurredFrom,
        @NotNull OffsetDateTime occurredTo,
        Integer guardHours,
        Integer significantDrivingMinutes,
        Integer mergeGapSeconds,
        Integer operatingPeriodSplitRestHours,
        Integer shiftEndMarkPeriodMinutes,
        Integer absenceBeginEndMinActivityMinutes,
        EsperActivityMergeMode activityMergeMode,
        EsperShiftResolutionMode shiftResolutionMode
) {
    public EsperPocRequest {
        if (occurredFrom != null && occurredTo != null && !occurredFrom.isBefore(occurredTo)) {
            throw new IllegalArgumentException("occurredFrom must be before occurredTo");
        }
        guardHours = guardHours == null ? 24 : Math.max(0, guardHours);
        significantDrivingMinutes = significantDrivingMinutes == null ? 3 : Math.max(1, significantDrivingMinutes);
        mergeGapSeconds = mergeGapSeconds == null ? 60 : Math.max(0, mergeGapSeconds);
        operatingPeriodSplitRestHours = operatingPeriodSplitRestHours == null ? 7 : Math.max(1, operatingPeriodSplitRestHours);
        shiftEndMarkPeriodMinutes = shiftEndMarkPeriodMinutes == null ? 420 : Math.max(1, shiftEndMarkPeriodMinutes);
        absenceBeginEndMinActivityMinutes = absenceBeginEndMinActivityMinutes == null ? 5 : Math.max(1, absenceBeginEndMinActivityMinutes);
    }
}
