using System.ComponentModel.DataAnnotations;

namespace JobsMedical.Web.Models;

/// <summary>A browser's Web Push subscription (PWA notifications). One row per device/browser.</summary>
public class WebPushSubscription
{
    public int Id { get; set; }

    [Required, MaxLength(600)]
    public string Endpoint { get; set; } = "";   // push service URL (unique key)

    [Required, MaxLength(200)]
    public string P256dh { get; set; } = "";      // client public key

    [Required, MaxLength(100)]
    public string Auth { get; set; } = "";        // client auth secret

    [MaxLength(36)]
    public string? VisitorId { get; set; }         // who subscribed (anonymous visitor)

    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}

/// <summary>Shape posted by the browser's PushManager.subscribe().toJSON().</summary>
public record PushSubscriptionDto(string? Endpoint, PushKeysDto? Keys);
public record PushKeysDto(string? P256dh, string? Auth);
