|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using Newtonsoft.Json; |
| 4 | +using Pingpp.Net; |
| 5 | +using Pingpp.Exception; |
| 6 | + |
| 7 | +namespace Pingpp.Models |
| 8 | +{ |
| 9 | + /// <summary> |
| 10 | + /// 签约对象 |
| 11 | + /// </summary> |
| 12 | + public class Agreement :Pingpp |
| 13 | + { |
| 14 | + [JsonProperty("id")] |
| 15 | + public string Id { get; set; } |
| 16 | + [JsonProperty("object")] |
| 17 | + public string Object { get; set; } |
| 18 | + [JsonProperty("livemode")] |
| 19 | + public bool Livemode { get; set; } |
| 20 | + [JsonProperty("app")] |
| 21 | + public string App { get; set; } |
| 22 | + [JsonProperty("created")] |
| 23 | + public int? Created { get; set; } |
| 24 | + [JsonProperty("channel")] |
| 25 | + public string Channel { get; set; } |
| 26 | + [JsonProperty("contract_no")] |
| 27 | + public string ContractNo { get; set; } |
| 28 | + [JsonProperty("contract_id")] |
| 29 | + public string ContractId { get; set; } |
| 30 | + [JsonProperty("credential")] |
| 31 | + public Dictionary<string, object> Credential { get; set; } |
| 32 | + [JsonProperty("status")] |
| 33 | + public string Status { get; set; } |
| 34 | + [JsonProperty("time_succeeded")] |
| 35 | + public int? TimeSucceeded { get; set; } |
| 36 | + [JsonProperty("time_canceled")] |
| 37 | + public int? TImeCanceled { get; set; } |
| 38 | + [JsonProperty("failure_code")] |
| 39 | + public string FailureCode { get; set; } |
| 40 | + [JsonProperty("failure_msg")] |
| 41 | + public string FailureMsg { get; set; } |
| 42 | + [JsonProperty("metadata")] |
| 43 | + public Dictionary<string, object> Metadata { get; set; } |
| 44 | + [JsonProperty("extra")] |
| 45 | + public Dictionary<string, object> Extra { get; set; } |
| 46 | + |
| 47 | + private const string BaseUrl = "/v1/agreements"; |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// 创建签约接口 |
| 51 | + /// </summary> |
| 52 | + /// <param name="param"></param> |
| 53 | + /// <returns></returns> |
| 54 | + public static Agreement Create(Dictionary<string, object> param) |
| 55 | + { |
| 56 | + var agreement = Requestor.DoRequest(BaseUrl, "POST", param); |
| 57 | + return Mapper<Agreement>.MapFromJson(agreement); |
| 58 | + } |
| 59 | + |
| 60 | + /// <summary> |
| 61 | + /// 查询签约对象 |
| 62 | + /// </summary> |
| 63 | + /// <param name="Id"></param> |
| 64 | + /// <returns></returns> |
| 65 | + public static Agreement Retrieve(string Id) |
| 66 | + { |
| 67 | + var agreement = Requestor.DoRequest(string.Format("{0}/{1}", BaseUrl, Id), "GET"); |
| 68 | + return Mapper<Agreement>.MapFromJson(agreement); |
| 69 | + } |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// 解除签约 |
| 73 | + /// </summary> |
| 74 | + /// <param name="Id"></param> |
| 75 | + /// <returns></returns> |
| 76 | + public static Agreement Cancel(string Id) |
| 77 | + { |
| 78 | + Dictionary<string, object> param = new Dictionary<string, object> {{ "status", "canceled" }}; |
| 79 | + var agreement = Requestor.DoRequest(string.Format("{0}/{1}", BaseUrl, Id), "PUT", param); |
| 80 | + return Mapper<Agreement>.MapFromJson(agreement); |
| 81 | + } |
| 82 | + |
| 83 | + /// <summary> |
| 84 | + /// 查询签约对象列表 |
| 85 | + /// </summary> |
| 86 | + /// <param name="listParams"></param> |
| 87 | + /// <returns></returns> |
| 88 | + public static AgreementList List(Dictionary<string, object> listParams) |
| 89 | + { |
| 90 | + var agreementList = Requestor.DoRequest(Requestor.FormatUrl(BaseUrl, Requestor.CreateQuery(listParams)), "GET"); |
| 91 | + return Mapper<AgreementList>.MapFromJson(agreementList); |
| 92 | + } |
| 93 | + } |
| 94 | +} |
0 commit comments