using System.Collections.Generic;
using Newtonsoft.Json;

namespace ZB.MOM.WW.GRAccess.Cli.Protocol
{
    public class PipeRequest
    {
        [JsonProperty("type")]
        public string Type { get; set; } = "execute";

        [JsonProperty("command")]
        public string Command { get; set; }

        [JsonProperty("subcommand")]
        public string Subcommand { get; set; }

        [JsonProperty("args")]
        public Dictionary<string, object> Args { get; set; } = new Dictionary<string, object>();

        public static PipeRequest Execute(string command, string subcommand, Dictionary<string, object> args = null)
        {
            return new PipeRequest
            {
                Type = "execute",
                Command = command,
                Subcommand = subcommand,
                Args = args ?? new Dictionary<string, object>()
            };
        }

        public static PipeRequest Shutdown() => new PipeRequest { Type = "shutdown" };

        public static PipeRequest Status() => new PipeRequest { Type = "status" };
    }
}
