using System; using System.Text; using Newtonsoft.Json; namespace Leadercraft.Server { internal class LeadercraftResult { private string _responseJson; public readonly int StatusCode; public bool IsError { get => StatusCode < 200 || StatusCode > 299; } public ResultStruct ParseResult() { return JsonConvert.DeserializeObject>(_responseJson); } public ResultStruct ParseError() { return JsonConvert.DeserializeObject>(_responseJson); } public LeadercraftResult(string response, int status = 200) { this._responseJson = response; this.StatusCode = status; } public LeadercraftResult(byte[] response, int status = 200) { this._responseJson = Encoding.ASCII.GetString(response); this.StatusCode = status; } } }