using Hcs.Broker.Api.Request.Adapter;

namespace Hcs.Broker.Api.Request
{
    public class RequestSingleResult<T>
    {
        public bool Ready { get; set; }

        public bool Success { get; set; }

        public T? Result { get; set; }

        public IErrorMessage? ErrorMessage { get; set; }

        public static RequestSingleResult<T> CreateNotReady()
        {
            return new RequestSingleResult<T>
            {
                Ready = false
            };
        }

        public static RequestSingleResult<T> CreateSuccessful(T result)
        {
            return new RequestSingleResult<T>
            {
                Ready = true,
                Success = true,
                Result = result
            };
        }

        public static RequestSingleResult<T> CreateFailed(IErrorMessage? errorMessage)
        {
            return new RequestSingleResult<T>
            {
                Ready = true,
                Success = false,
                ErrorMessage = errorMessage
            };
        }
    }
}
