using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace cuidian.OpenApi.Utils
{
public abstract class ApiResponse
{
public ApiResponse(Http.Response resp)
{
this.Response = resp;
}
[JsonIgnore]
Http.Response Response { get; set; }
///
/// 错误码
///
[JsonProperty("errcode")]
public string ErrCode { get; set; }
///
/// 错误信息
///
[JsonProperty("errmsg")]
public string ErrMsg { get; set; }
///
/// 响应原始内容
///
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string HttpBodyString { get; set; }
///
/// 交易号
///
[JsonProperty("tradeid", NullValueHandling = NullValueHandling.Ignore)]
public string TradeId { get; set; }
///
/// 新增资源返回的id
///
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public string Id { get; set; }
///
/// 批量查询(batch_get)返回的页号
///
[JsonProperty("page_index", NullValueHandling = NullValueHandling.Ignore)]
public int? PageIndex { get; set; }
///
/// 批量查询(batch_get)返回的总行数
///
[JsonProperty("row_count", NullValueHandling = NullValueHandling.Ignore)]
public int? RowCount { get; set; }
///
/// 批量查询(batch_get)返回的每页行数
///
[JsonProperty("rows_per_page", NullValueHandling = NullValueHandling.Ignore)]
public int? RowsPerPage { get; set; }
///
/// 批量查询(batch_get)返回的页数
///
[JsonProperty("page_count", NullValueHandling = NullValueHandling.Ignore)]
public int? PageCount { get; set; }
///
/// HTTP 原生响应
///
[JsonIgnore]
public string NativeResponseString { get; set; }
///
/// 响应结果是否错误
///
[JsonIgnore]
public bool IsError
{
get
{
if (string.IsNullOrEmpty(this.ErrCode))
this.ErrCode = "0";
return !this.ErrCode.Equals("0");
}
}
}
}