copiers_change.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 addCopiers():
  9. """
  10. 添加抄送方
  11. :return:
  12. """
  13. sign_flowId = "df********grgter" # 声明变量入参
  14. body = {
  15. "copiers": [
  16. {
  17. "copierOrgInfo": {
  18. "orgName": "这是个抄送通知企业的名称",
  19. "orgId": ""
  20. },
  21. "copierPsnInfo": {
  22. "psnAccount": "153****7650",
  23. "psnId": ""
  24. }
  25. }
  26. ]
  27. } # 构建请求body体
  28. api_path = "/v3/sign-flow/{}/copiers".format(sign_flowId) # 拼接请求路径
  29. method = esigntool.httpMethodEnum.POST # 声明请求方法
  30. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
  31. method, api_path, body) # 签名并构造签名鉴权json请求头
  32. resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
  33. print(resp.text)
  34. return resp
  35. @esign_run_print_outer
  36. def deleteCopiers():
  37. """
  38. 删除签署区
  39. :return:
  40. """
  41. sign_flowId = "df********grgter" # 声明变量入参
  42. body = {
  43. "copiers": [
  44. {
  45. "copierPsnInfo": {
  46. "psnId": "",
  47. "psnAccount": "151****0101"
  48. },
  49. "copierOrgInfo": {
  50. "orgId": "",
  51. "orgName": "这是个抄送方的企业名称"
  52. }
  53. }
  54. ]
  55. } # 构建请求body体
  56. api_path = "/v3/sign-flow/{}/copiers/delete".format(sign_flowId) # 拼接请求路径
  57. method = esigntool.httpMethodEnum.POST # 声明请求方法
  58. json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
  59. method, api_path, body) # 签名并构造签名鉴权json请求头
  60. resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
  61. print(resp.text)
  62. return resp
  63. if __name__ == '__main__':
  64. addCopiers() # 添加抄送方
  65. deleteCopiers() # 删除抄送方