using System.Net;

namespace Leanetec.EConnect.Domain.Entities;

public record Response<TError>() where TError : class
{
    public bool Ok { get; init; }

    private HttpStatusCode? _statusCode;

    public HttpStatusCode StatusCode
    {
        get => _statusCode ?? (Ok ? HttpStatusCode.OK : HttpStatusCode.InternalServerError);
        init => _statusCode = value;
    }

    public int StatusCodeInt => (int)StatusCode;

    public TError? Error { get; init; }
}

public record Response<TData, TError> : Response<TError> where TData : class where TError : class
{
    public TData? Data { get; init; }
}