package com.cameleer.server.app.alerting.dto;

import com.cameleer.server.core.alerting.AlertNotification;
import com.cameleer.server.core.alerting.NotificationStatus;

import java.time.Instant;
import java.util.UUID;

public record AlertNotificationDto(
        UUID id,
        UUID alertInstanceId,
        UUID webhookId,
        UUID outboundConnectionId,
        NotificationStatus status,
        int attempts,
        Instant nextAttemptAt,
        Integer lastResponseStatus,
        String lastResponseSnippet,
        Instant deliveredAt,
        Instant createdAt
) {
    public static AlertNotificationDto from(AlertNotification n) {
        return new AlertNotificationDto(
                n.id(), n.alertInstanceId(), n.webhookId(), n.outboundConnectionId(),
                n.status(), n.attempts(), n.nextAttemptAt(),
                n.lastResponseStatus(), n.lastResponseSnippet(),
                n.deliveredAt(), n.createdAt());
    }
}
