Client.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // This file is auto-generated, don't edit it. Thanks.
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Threading.Tasks;
  7. using Tea;
  8. using Tea.Utils;
  9. namespace Alipay.EasySDK.Util.AES
  10. {
  11. public class Client
  12. {
  13. protected Alipay.EasySDK.Kernel.Client _kernel;
  14. public Client(Alipay.EasySDK.Kernel.Client kernel)
  15. {
  16. this._kernel = kernel;
  17. }
  18. public string Decrypt(string cipherText)
  19. {
  20. return this._kernel.AesDecrypt(cipherText, this._kernel.GetConfig("encryptKey"));
  21. }
  22. public string Encrypt(string plainText)
  23. {
  24. return this._kernel.AesEncrypt(plainText, this._kernel.GetConfig("encryptKey"));
  25. }
  26. /// <summary>
  27. /// ISV代商户代用,指定appAuthToken
  28. /// </summary>
  29. /// <param name="appAuthToken">代调用token</param>
  30. /// <returns>本客户端,便于链式调用</returns>
  31. public Client Agent(string appAuthToken)
  32. {
  33. _kernel.InjectTextParam("app_auth_token", appAuthToken);
  34. return this;
  35. }
  36. /// <summary>
  37. /// 用户授权调用,指定authToken
  38. /// </summary>
  39. /// <param name="authToken">用户授权token</param>
  40. /// <returns>本客户端,便于链式调用</returns>
  41. public Client Auth(string authToken)
  42. {
  43. _kernel.InjectTextParam("auth_token", authToken);
  44. return this;
  45. }
  46. /// <summary>
  47. /// 设置异步通知回调地址,此处设置将在本调用中覆盖Config中的全局配置
  48. /// </summary>
  49. /// <param name="url">异步通知回调地址,例如:https://www.test.com/callback </param>
  50. /// <returns>本客户端,便于链式调用</returns>
  51. public Client AsyncNotify(string url)
  52. {
  53. _kernel.InjectTextParam("notify_url", url);
  54. return this;
  55. }
  56. /// <summary>
  57. /// 将本次调用强制路由到后端系统的测试地址上,常用于线下环境内外联调,沙箱与线上环境设置无效
  58. /// </summary>
  59. /// <param name="testUrl">后端系统测试地址</param>
  60. /// <returns>本客户端,便于链式调用</returns>
  61. public Client Route(string testUrl)
  62. {
  63. _kernel.InjectTextParam("ws_service_url", testUrl);
  64. return this;
  65. }
  66. /// <summary>
  67. /// 设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
  68. /// </summary>
  69. /// <param name="key">业务请求参数名称(biz_content下的字段名,比如timeout_express)</param>
  70. /// <param name="value">
  71. /// 业务请求参数的值,一个可以序列化成JSON的对象
  72. /// 如果该字段是一个字符串类型(String、Price、Date在SDK中都是字符串),请使用string储存
  73. /// 如果该字段是一个数值型类型(比如:Number),请使用long储存
  74. /// 如果该字段是一个复杂类型,请使用嵌套的Dictionary指定各下级字段的值
  75. /// 如果该字段是一个数组,请使用List储存各个值
  76. /// 对于更复杂的情况,也支持Dictionary和List的各种组合嵌套,比如参数是值是个List,List中的每种类型是一个复杂对象
  77. /// </param>
  78. /// <returns>本客户端,便于链式调用</returns>
  79. public Client Optional(string key, object value)
  80. {
  81. _kernel.InjectBizParam(key, value);
  82. return this;
  83. }
  84. /// <summary>
  85. /// 批量设置API入参中没有的其他可选业务请求参数(biz_content下的字段)
  86. /// optional方法的批量版本
  87. /// </summary>
  88. /// <param name="optionalArgs">可选参数集合,每个参数由key和value组成,key和value的格式请参见optional方法的注释</param>
  89. /// <returns>本客户端,便于链式调用</returns>
  90. public Client BatchOptional(Dictionary<string, object> optionalArgs)
  91. {
  92. foreach (var pair in optionalArgs)
  93. {
  94. _kernel.InjectBizParam(pair.Key, pair.Value);
  95. }
  96. return this;
  97. }
  98. }
  99. }