signflow_change.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # -*- coding: UTF-8 -*-
  2. import esigntool
  3. import requests
  4. from esigntool import esign_run_print_outer
  5. # 合同文件签署服务API - 签署流程 - 变更类
  6. config = esigntool.config() # 初始化配置类
  7. @esign_run_print_outer
  8. def signFlowStart():
  9. """
  10. 开启签署流程
  11. :return:
  12. """
  13. sign_flowId = "fr5845******834y656" # 声明变量入参
  14. api_path = "/v3/sign-flow/{}/start".format(sign_flowId) # 拼接请求路径
  15. method = esigntool.httpMethodEnum.POST # 声明请求方法
  16. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
  17. method, api_path) # 签名并构造签名鉴权json请求头
  18. resp = requests.request(method, config.host + api_path, json=None, headers=json_headers) # 发送请求
  19. print(resp.text)
  20. return resp
  21. @esign_run_print_outer
  22. def signFlowFinish():
  23. """
  24. 完结签署流程
  25. :return:
  26. """
  27. sign_flowId = "fr5845******834y656" # 声明变量入参
  28. api_path = "/v3/sign-flow/{}/finish".format(sign_flowId) # 拼接请求路径
  29. method = esigntool.httpMethodEnum.POST # 声明请求方法
  30. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
  31. method, api_path) # 签名并构造签名鉴权json请求头
  32. resp = requests.request(method, config.host + api_path, json=None, headers=json_headers) # 发送请求
  33. print(resp.text)
  34. return resp
  35. @esign_run_print_outer
  36. def signFlowRevoke():
  37. """
  38. 撤销签署流程
  39. :return:
  40. """
  41. sign_flowId = "fr5845******834y656" # 声明变量入参
  42. api_path = "/v3/sign-flow/{}/revoke".format(sign_flowId) # 拼接请求路径
  43. method = esigntool.httpMethodEnum.POST # 声明请求方法
  44. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
  45. method, api_path) # 签名并构造签名鉴权json请求头
  46. resp = requests.request(method, config.host + api_path, json=None, headers=json_headers) # 发送请求
  47. print(resp.text)
  48. return resp
  49. @esign_run_print_outer
  50. def signFlowDelay():
  51. """
  52. 延期签署截止时间
  53. :return:
  54. """
  55. sign_flowId = "fr5845******834y656" # 声明变量入参
  56. body = {
  57. "signFlowExpireTime": 1654849671000
  58. } # 构建请求body体
  59. api_path = "/v3/sign-flow/{}/delay".format(sign_flowId) # 拼接请求路径
  60. method = esigntool.httpMethodEnum.POST # 声明请求方法
  61. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
  62. method, api_path, body) # 签名并构造签名鉴权json请求头
  63. resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
  64. print(resp.text)
  65. return resp
  66. @esign_run_print_outer
  67. def signFlowUrge():
  68. """
  69. 催签流程中签署人
  70. :return:
  71. """
  72. sign_flowId = "fr5845******834y656" # 声明变量入参
  73. body = {
  74. "noticeTypes": "1",
  75. "urgedOperator": {
  76. "psnAccount": "183****0101"
  77. }
  78. } # 构建请求body体
  79. api_path = "/v3/sign-flow/{}/urge".format(sign_flowId) # 拼接请求路径
  80. method = esigntool.httpMethodEnum.POST # 声明请求方法
  81. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
  82. method, api_path, body) # 签名并构造签名鉴权json请求头
  83. resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
  84. print(resp.text)
  85. return resp
  86. if __name__ == '__main__':
  87. signFlowStart() # 开启签署流程
  88. signFlowFinish() # 完结签署流程
  89. signFlowRevoke() # 撤销签署流程
  90. signFlowDelay() # 延期签署截止时间
  91. signFlowUrge() # 催签流程中签署人