using Newtonsoft.Json;

namespace InABox.DatabaseProxy
{
    public class Credentials
    {
        private static readonly string cacheToken = Guid.NewGuid().ToString().Replace("-", "");

        public string CacheToken => cacheToken;

        public string UserID { get; set; }

        public string Password { get; set; }
    }

    public class Request
    {
        public Request()
        {
            Credentials = new Credentials();
        }

        public Credentials Credentials { get; set; }

        public string Database { get; set; }

        public string SQL { get; set; }

        public string AsJSON()
        {
            return JsonConvert.SerializeObject(this);
        }

        ~Request()
        {
            Credentials = null;
        }

        public override string ToString()
        {
            return SQL;
        }
    }

    public class Response
    {
        public Response()
        {
            Status = "INCOMPLETE";
            Data = new List<List<object>>();
        }

        public string Status { get; set; }

        public List<List<object>> Data { get; private set; }

        ~Response()
        {
            Data = null;
        }
    }
}