namespace adas_core.Domain.Models.Responses;

/// <summary>
/// Represents a generic response wrapper that encapsulates a payload of type <typeparamref name="T"/> along with associated response metadata.
/// </summary>
/// <typeparam name="T">The type of the payload contained within the response.</typeparam>
/// <!-- aidoc:v1 sig=1410d00 -->
public class Response<T>
{
    /// <summary>
    /// Initializes a new instance of the <see cref="Response"/> class using default values.
    /// </summary>
    /// <!-- aidoc:v1 sig=c192431 body=4448e1d -->
    public Response()
    {
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="Response{T}"/> class representing a successful result, setting <see cref="Response{T}.Succeeded"/> to <c>true</c>, <see cref="Response{T}.Message"/> to an empty string, <see cref="Response{T}.Errors"/> to <c>null</c>, and storing the supplied payload in <see cref="Response{T}.Data"/>.
    /// </summary>
    /// <param name="data">The payload to expose through <see cref="Response{T}.Data"/>.</param>
    /// <!-- aidoc:v1 sig=f4d0833 body=8db513f -->
    public Response(T data)
    {
        Succeeded = true;
        Message = string.Empty;
        Errors = null;
        Data = data;
    }

    public T? Data { get; set; }
    public bool? Succeeded { get; set; }

    public string[]? Errors { get; set; }
    public string? Message { get; set; }
}

public record UpdateResponse<T>(long Changes, T? Data);