package com.r35157.jupiterperpsalarm.impl.ref;

import com.r35157.jupiterperpsalarm.AlarmSeverity;

import java.util.Map;
import java.util.Objects;

public record PushoverAlarmActionConfiguration(
        String applicationToken,
        String userKey,
        Map<Integer, Notification> notifications
) {
    public PushoverAlarmActionConfiguration {
        Objects.requireNonNull(applicationToken, "applicationToken");
        Objects.requireNonNull(userKey, "userKey");
        notifications = Map.copyOf(notifications);

        if (applicationToken.isBlank()) {
            throw new IllegalArgumentException("Application token cannot be blank");
        }
        if (userKey.isBlank()) {
            throw new IllegalArgumentException("User key cannot be blank");
        }
    }

    public record Notification(
            AlarmSeverity severity,
            String note
    ) {
        public Notification {
            Objects.requireNonNull(severity, "severity");
            Objects.requireNonNull(note, "note");
        }
    }
}
