You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.1 KiB
91 lines
2.1 KiB
using System;
|
|
using System.Xml.Serialization;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace Jd.Api
|
|
{
|
|
/// <summary>
|
|
/// 京东接口返回数据
|
|
/// </summary>
|
|
[Serializable]
|
|
public abstract class JdResponse
|
|
{
|
|
/// <summary>
|
|
/// 错误码
|
|
/// </summary>
|
|
[XmlElement("code")]
|
|
[JsonProperty("code")]
|
|
public String ErrCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 错误信息
|
|
/// </summary>
|
|
public virtual String ErrMsg
|
|
{
|
|
get
|
|
{
|
|
return ZhErrMsg;
|
|
}
|
|
|
|
internal set
|
|
{
|
|
this.ZhErrMsg = value;
|
|
}
|
|
}
|
|
|
|
[XmlElement("zh_desc")]
|
|
[JsonProperty("zh_desc")]
|
|
public String ZhErrMsg { get; set; }
|
|
|
|
/// <summary>
|
|
/// 英文错误信息
|
|
/// </summary>
|
|
[XmlElement("en_desc")]
|
|
[JsonProperty("en_desc")]
|
|
public String EnErrMsg { get; set; }
|
|
|
|
public string RealErrorMsg
|
|
{
|
|
get
|
|
{
|
|
if (IsError)
|
|
return string.IsNullOrEmpty(ErrorMsg) ? ErrMsg : ErrorMsg;
|
|
else
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 响应原始内容
|
|
/// </summary>
|
|
public String Body { get; set; }
|
|
|
|
public int Error { get; set; }
|
|
public String ErrorMsg { get; set; }
|
|
/// <summary>
|
|
/// 响应的JSON object
|
|
/// </summary>
|
|
public JObject Json { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// HTTP GET请求的URL
|
|
/// </summary>
|
|
public String ReqUrl { get; set; }
|
|
|
|
/// <summary>
|
|
/// 响应结果是否错误
|
|
/// </summary>
|
|
public virtual Boolean IsError
|
|
{
|
|
get
|
|
{
|
|
return (!string.IsNullOrEmpty(this.ErrCode)
|
|
&& !String.Equals(this.ErrCode, "0", StringComparison.InvariantCultureIgnoreCase)
|
|
)
|
|
|| !string.IsNullOrEmpty(this.ErrMsg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|