using Newtonsoft.Json;

namespace ZB.MOM.WW.GRAccess.Cli.Protocol
{
    public class PipeResponse
    {
        [JsonProperty("success")]
        public bool Success { get; set; }

        [JsonProperty("output")]
        public string Output { get; set; }

        [JsonProperty("error")]
        public string Error { get; set; }

        [JsonProperty("exitCode")]
        public int ExitCode { get; set; }

        public static PipeResponse Ok(string output) => new PipeResponse
        {
            Success = true,
            Output = output,
            ExitCode = 0
        };

        public static PipeResponse Fail(string error, int exitCode = 1) => new PipeResponse
        {
            Success = false,
            Error = error,
            ExitCode = exitCode
        };
    }
}
