using System;
using System.Text.Json.Serialization;

namespace Jellyfin.Plugin.SRFPlay.Api.Models;

/// <summary>
/// A scheduled or active recording.
/// </summary>
public class RecordingEntry
{
    /// <summary>
    /// Gets or sets the unique recording ID.
    /// </summary>
    [JsonPropertyName("id")]
    public string Id { get; set; } = string.Empty;

    /// <summary>
    /// Gets or sets the SRF URN.
    /// </summary>
    [JsonPropertyName("urn")]
    public string Urn { get; set; } = string.Empty;

    /// <summary>
    /// Gets or sets the business unit this recording belongs to (e.g. "srf", "rts").
    /// Used to show recordings under the matching unit's channel.
    /// </summary>
    [JsonPropertyName("businessUnit")]
    public string BusinessUnit { get; set; } = string.Empty;

    /// <summary>
    /// Gets or sets the title.
    /// </summary>
    [JsonPropertyName("title")]
    public string Title { get; set; } = string.Empty;

    /// <summary>
    /// Gets or sets the description.
    /// </summary>
    [JsonPropertyName("description")]
    public string? Description { get; set; }

    /// <summary>
    /// Gets or sets the image URL.
    /// </summary>
    [JsonPropertyName("imageUrl")]
    public string? ImageUrl { get; set; }

    /// <summary>
    /// Gets or sets when the livestream starts.
    /// </summary>
    [JsonPropertyName("validFrom")]
    public DateTime? ValidFrom { get; set; }

    /// <summary>
    /// Gets or sets when the livestream ends.
    /// </summary>
    [JsonPropertyName("validTo")]
    public DateTime? ValidTo { get; set; }

    /// <summary>
    /// Gets or sets the recording state.
    /// </summary>
    [JsonPropertyName("state")]
    public RecordingState State { get; set; } = RecordingState.Scheduled;

    /// <summary>
    /// Gets or sets the output file path.
    /// </summary>
    [JsonPropertyName("outputPath")]
    public string? OutputPath { get; set; }

    /// <summary>
    /// Gets or sets when the recording actually started.
    /// </summary>
    [JsonPropertyName("recordingStartedAt")]
    public DateTime? RecordingStartedAt { get; set; }

    /// <summary>
    /// Gets or sets when the recording ended.
    /// </summary>
    [JsonPropertyName("recordingEndedAt")]
    public DateTime? RecordingEndedAt { get; set; }

    /// <summary>
    /// Gets or sets the file size in bytes.
    /// </summary>
    [JsonPropertyName("fileSizeBytes")]
    public long? FileSizeBytes { get; set; }

    /// <summary>
    /// Gets or sets the error message if recording failed.
    /// </summary>
    [JsonPropertyName("errorMessage")]
    public string? ErrorMessage { get; set; }

    /// <summary>
    /// Gets or sets when this entry was created.
    /// </summary>
    [JsonPropertyName("createdAt")]
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
