| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- # -*- coding: UTF-8 -*-
- import esigntool
- import requests
- from esigntool import esign_run_print_outer
- # 合同文件签署服务API - 待签文件及附属材料 - 变更类
- config = esigntool.config() # 初始化配置类
- @esign_run_print_outer
- def addUnsignedFiles():
- """
- 追加待签文件
- :return:
- """
- body = {
- "unsignedFiles": [
- {
- "fileId": "ea3151a8d***a53d3f4c",
- "fileName": "入职证明.pdf"
- }
- ]
- }
- # 构建请求body体
- sign_flowId = "df********grgter" # 声明变量入参
- api_path = "/v3/sign-flow/{}/unsigned-files".format(sign_flowId) # 拼接请求路径
- method = esigntool.httpMethodEnum.POST # 声明请求方法
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
- method, api_path, body) # 计算签名并构造签名鉴权json请求头
- resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
- print(resp.text)
- return resp
- @esign_run_print_outer
- def deleteUnsignedFiles():
- """
- 删除待签署文件
- :return:
- """
- sign_flowId = "df********grgter" # 声明变量入参
- sign_FieldIds = "urerutheirt" # 声明变量入参
- api_path = "/v3/sign-flow/{}/unsigned-files?fileIds={}".format(sign_flowId, sign_FieldIds) # 拼接请求路径
- method = esigntool.httpMethodEnum.DELETE # 声明请求方法
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
- method, api_path) # 签名并构造签名鉴权json请求头
- resp = requests.request(method, config.host + api_path, json=None, headers=json_headers) # 发送请求
- print(resp.text)
- return resp
- @esign_run_print_outer
- def addAttachments():
- """
- 追加附属材料
- :return:
- """
- body = {
- "attachmentList": [
- {
- "fileId": "ea3151***a53d3f4c",
- "fileName": "入职手册.pdf"
- }
- ]
- }
- # 构建请求body体
- sign_flowId = "df********grgter" # 声明变量入参
- api_path = "/v3/sign-flow/{}/attachments".format(sign_flowId) # 拼接请求路径
- method = esigntool.httpMethodEnum.POST # 声明请求方法
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
- method, api_path, body) # 计算签名并构造签名鉴权json请求头
- resp = requests.request(method, config.host + api_path, json=body, headers=json_headers) # 发送请求
- print(resp.text)
- return resp
- @esign_run_print_outer
- def deleteAttachments():
- """
- 删除附属材料
- :return:
- """
- sign_flowId = "df********grgter" # 声明变量入参
- sign_FieldIds = "xxx1,xxx2" # 声明变量入参
- api_path = "/v3/sign-flow/{}/attachments?fileIds={}".format(sign_flowId, sign_FieldIds) # 拼接请求路径
- method = esigntool.httpMethodEnum.DELETE # 声明请求方法
- json_headers = esigntool.buildSignJsonHeader(config.appId, config.scert,
- method, api_path) # 签名并构造签名鉴权json请求头
- resp = requests.request(method, config.host + api_path, json=None, headers=json_headers) # 发送请求
- print(resp.text)
- return resp
- if __name__ == '__main__':
- addUnsignedFiles() # 追加待签文件
- deleteUnsignedFiles() # 删除待签署文件
- addAttachments() # 追加附属材料
- deleteAttachments() # 删除附属材料
|