BaseQimenCloudRequest.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using Top.Api;
  4. namespace QimenCloud.Api
  5. {
  6. public abstract class BaseQimenCloudRequest<T> : IQimenCloudRequest<T> where T : QimenCloudResponse
  7. {
  8. /// <summary>
  9. /// HTTP请求URL参数
  10. /// </summary>
  11. protected TopDictionary otherParams;
  12. /// <summary>
  13. /// HTTP请求头参数
  14. /// </summary>
  15. private TopDictionary headerParams;
  16. /// <summary>
  17. /// 请求目标AppKey
  18. /// </summary>
  19. private string targetAppKey;
  20. /// <summary>
  21. /// 批量API请求的用户授权码
  22. /// </summary>
  23. private string batchApiSession;
  24. /// <summary>
  25. /// API在批量调用中的顺序
  26. /// </summary>
  27. private int batchApiOrder;
  28. public void AddOtherParameter(string key, string value)
  29. {
  30. if (this.otherParams == null)
  31. {
  32. this.otherParams = new TopDictionary();
  33. }
  34. this.otherParams.Add(key, value);
  35. }
  36. public void AddHeaderParameter(string key, string value)
  37. {
  38. GetHeaderParameters().Add(key, value);
  39. }
  40. public IDictionary<string, string> GetHeaderParameters()
  41. {
  42. if (this.headerParams == null)
  43. {
  44. this.headerParams = new TopDictionary();
  45. }
  46. return this.headerParams;
  47. }
  48. public string GetTargetAppKey()
  49. {
  50. return this.targetAppKey;
  51. }
  52. public void SetTargetAppKey(string targetAppKey)
  53. {
  54. this.targetAppKey = targetAppKey;
  55. }
  56. public string GetBatchApiSession()
  57. {
  58. return this.batchApiSession;
  59. }
  60. public void SetBatchApiSession(string session)
  61. {
  62. this.batchApiSession = session;
  63. }
  64. public int GetBatchApiOrder()
  65. {
  66. return this.batchApiOrder;
  67. }
  68. public void SetBatchApiOrder(int order)
  69. {
  70. this.batchApiOrder = order;
  71. }
  72. public abstract string GetApiName();
  73. public abstract void Validate();
  74. public abstract IDictionary<string, string> GetParameters();
  75. }
  76. }