using System; using System.Collections.Generic; using System.Web.Script.Serialization; namespace Retailcrm { /// /// Response /// public class Response { private readonly int _statusCode; private readonly string _rawResponse; private readonly Dictionary _responseData; /// /// Response constructor /// /// /// /// public Response(int statusCode, string responseBody = null) { _statusCode = statusCode; if (string.IsNullOrEmpty(responseBody)) { throw new ArgumentException("Response body is empty"); } _rawResponse = responseBody; var jsSerializer = new JavaScriptSerializer(); _responseData = (Dictionary)jsSerializer.DeserializeObject(responseBody); } /// /// Get response status code /// /// public int GetStatusCode() { return _statusCode; } /// /// Get response body data /// /// public Dictionary GetResponse() { return _responseData; } /// /// Get raw response body /// /// public string GetRawResponse() { return _rawResponse; } /// /// Check response is successfull /// /// public bool IsSuccessfull() { return _statusCode < 400; } } }