using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace SinochemCloudClient.Models
{ 

    public abstract class ResponseBase : EventArgs
    {
        public const string SuccessResponse = "200";

        public string code { get; set; }
        public string msg { get; set; }

        public bool IsSuccessful()
        {
            return SuccessResponse == code;
        }

        public override string ToString()
        {
            PropertyInfo[] _PropertyInfos = this.GetType().GetProperties();

            var sb = new StringBuilder();

            foreach (var info in _PropertyInfos)
            {
                var value = info.GetValue(this, null) ?? "(null)";
                sb.AppendLine(info.Name + ": " + value.ToString());
            }

            return sb.ToString();
        }
    }
}