|
|
@@ -0,0 +1,403 @@
|
|
|
+import requests
|
|
|
+
|
|
|
+import esigntool
|
|
|
+from esigntool import esign_run_print_outer
|
|
|
+
|
|
|
+# 印章服务API
|
|
|
+
|
|
|
+config = esigntool.config() # 初始化配置类
|
|
|
+
|
|
|
+
|
|
|
+@esign_run_print_outer
|
|
|
+def create_templateseals():
|
|
|
+ """
|
|
|
+ 创建机构模板印章
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+ "orgId": "0c5bd492**8bfbf",
|
|
|
+ "sealName": "xx企业公章",
|
|
|
+ "sealTemplateStyle": "PUBLIC_ROUND_STAR",
|
|
|
+ "sealOpacity": "100",
|
|
|
+ "sealColor": "RED",
|
|
|
+ "sealOldStyle": "OLD_12",
|
|
|
+ "sealSize": "40_40"
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seals/create-by-template" # 拼接请求路径
|
|
|
+ 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 create_orgimage():
|
|
|
+ """
|
|
|
+ 创建机构图片印章
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+ "orgId": "0c5bd492**48bfbf",
|
|
|
+ "sealImageFileKey": "$c3c7170e-xx-xx-xx-xx",
|
|
|
+ "sealName": "这是一个自定义的印章名称",
|
|
|
+ "sealWidth": "20",
|
|
|
+ "sealHeight": "10",
|
|
|
+ "sealBizType": "CONTRACT"
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seals/create-by-image" # 拼接请求路径
|
|
|
+ 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 internal_auth():
|
|
|
+ """
|
|
|
+ 内部成员授权
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+ "orgId": "0c5bd49***48bfbf",
|
|
|
+ "sealId": "02590082-xx-xx-xx-2138db4d7b73",
|
|
|
+ "effectiveTime": 1636525541000,
|
|
|
+ "expireTime": 1668061541000,
|
|
|
+ "transactorPsnId": "c7e0029***10541e7",
|
|
|
+ "authorizedPsnIds": ["7ffcae***f0a8f6", "00371e8***c21ed09"],
|
|
|
+ "sealAuthScope": {
|
|
|
+ "templateIds": ["ALL"]
|
|
|
+ },
|
|
|
+ "sealRole": "SEAL_EXAMINER",
|
|
|
+ "redirectUrl": "https://www.xxx.cn/"
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seals/internal-auth" # 拼接请求路径
|
|
|
+ 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 external_auth():
|
|
|
+ """
|
|
|
+ 跨企业授权
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+ "orgId": "0c5bd49**648bfbf",
|
|
|
+ "effectiveTime": 1636525541000,
|
|
|
+ "expireTime": 1668061541000,
|
|
|
+ "transactorPsnId": "c7e00294**41e7",
|
|
|
+ "authorizedOrgInfo": {
|
|
|
+ "orgName": "这是一个受托企业的名称",
|
|
|
+ "orgIDCardNum": "91330108******1222"
|
|
|
+ },
|
|
|
+ "sealId": "02590082-xx-xx-xx-2138db4d7b73",
|
|
|
+ "redirectUrl": "https://www.xx.cn/"
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seals/internal-auth" # 拼接请求路径
|
|
|
+ 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 auth_delete():
|
|
|
+ """
|
|
|
+ 解除印章授权
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+ "orgId": "0c5bd492**48bfbf",
|
|
|
+ "deleteType": "sealIds",
|
|
|
+ "sealIds": ["02590082-xx-xx-xx-2138db4d7b73", "a1ccfad7-xx-xx-xx-84c51bf3a7e4"]
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seals/auth-delete" # 拼接请求路径
|
|
|
+ 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 authorization():
|
|
|
+ """
|
|
|
+ 查询授权书签署链接
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ orgId = "c7e00290541e7"
|
|
|
+ sealAuthBizId = "1caebb40***31f7f95087de"
|
|
|
+ api_path = "/v3/seals/org-seals/authorization-sign-url?orgId={}&sealAuthBizId={}".format(orgId,
|
|
|
+ sealAuthBizId) # 拼接请求路径
|
|
|
+ method = esigntool.httpMethodEnum.GET # 声明请求方法
|
|
|
+ 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 internal_detail():
|
|
|
+ """
|
|
|
+ 查询对内部成员授权详情
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+
|
|
|
+ orgId = "c7e00290541e7"
|
|
|
+ pageNum = "11"
|
|
|
+ pageSize = "22"
|
|
|
+ sealId = "02590082-**-**-**-2138db4d7b73"
|
|
|
+
|
|
|
+ api_path = "/v3/seals/org-seals/internal-auth?orgId={}&pageNum={}&pageSize={}&sealId={}".format(orgId, pageNum,
|
|
|
+ pageSize,
|
|
|
+ sealId) # 拼接请求路径
|
|
|
+ method = esigntool.httpMethodEnum.GET # 声明请求方法
|
|
|
+ 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 external_detail():
|
|
|
+ """
|
|
|
+ 查询对外部企业授权详情
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+
|
|
|
+ orgId = "c7e00290541e7"
|
|
|
+ pageNum = "11"
|
|
|
+ pageSize = "22"
|
|
|
+ sealId = "02590082-**-**-**-2138db4d7b73"
|
|
|
+
|
|
|
+ api_path = "/v3/seals/org-seals/external-auth?orgId={}&pageNum={}&pageSize={}&sealId={}".format(orgId, pageNum,
|
|
|
+ pageSize,
|
|
|
+ sealId) # 拼接请求路径
|
|
|
+ method = esigntool.httpMethodEnum.GET # 声明请求方法
|
|
|
+ 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 reauthorization():
|
|
|
+ """
|
|
|
+ 修改印章授权期限
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+ "sealAuthBizId": "7eb81942-xx-xx-xx-b59aa2ba479f",
|
|
|
+ "orgId": "0c5bd4924***5648bfbf",
|
|
|
+ "transactorPsnId": "c7e002***ea310541e7",
|
|
|
+ "effectiveTime": "1636525541000",
|
|
|
+ "expireTime": "1668061541000",
|
|
|
+ "redirectUrl": "http://www.xxx.cn/"
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seals/reauthorization" # 拼接请求路径
|
|
|
+ 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 own_seal():
|
|
|
+ """
|
|
|
+ 查询企业内部印章
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+
|
|
|
+ orgId = "c7e00290541e7"
|
|
|
+ pageNum = "11"
|
|
|
+ pageSize = "22"
|
|
|
+ sealId = "02590082-**-**-**-2138db4d7b73"
|
|
|
+
|
|
|
+ api_path = "/v3/seals/org-own-seal-list?orgId={}&pageNum={}&pageSize={}&sealId={}".format(orgId, pageNum,
|
|
|
+ pageSize,
|
|
|
+ sealId) # 拼接请求路径
|
|
|
+ method = esigntool.httpMethodEnum.GET # 声明请求方法
|
|
|
+ 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 authorized_seal():
|
|
|
+ """
|
|
|
+ 查询被外部企业授权印章
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+
|
|
|
+ orgId = "c7e00290541e7"
|
|
|
+ pageNum = "11"
|
|
|
+ pageSize = "22"
|
|
|
+
|
|
|
+ api_path = "/v3/seals/org-authorized-seal-list?orgId={}&pageNum={}&pageSize={}".format(orgId, pageNum,
|
|
|
+ pageSize) # 拼接请求路径
|
|
|
+ method = esigntool.httpMethodEnum.GET # 声明请求方法
|
|
|
+ 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 info_seal():
|
|
|
+ """
|
|
|
+ 查询指定印章详情(机构)
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+
|
|
|
+ orgId = "c7e00290541e7"
|
|
|
+ sealId = "02590082-**-**-**-2138db4d7b73"
|
|
|
+
|
|
|
+ api_path = "/v3/seals/org-seal-info?orgId={}&sealId={}".format(orgId, sealId) # 拼接请求路径
|
|
|
+ method = esigntool.httpMethodEnum.GET # 声明请求方法
|
|
|
+ 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 default_seal():
|
|
|
+ """
|
|
|
+ 设置机构默认印章
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+ "orgId": "c7e0029***41e7",
|
|
|
+ "sealId": "b984059f-xx-xx-xx-7e09a890b929"
|
|
|
+
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seals/set-default-seal" # 拼接请求路径
|
|
|
+ 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 orgseals_delete():
|
|
|
+ """
|
|
|
+ 删除机构印章
|
|
|
+ :return:DELETE
|
|
|
+ """
|
|
|
+
|
|
|
+ orgId = "c7e00290541e7"
|
|
|
+ sealId = "1caebb40***31f7f95087de"
|
|
|
+
|
|
|
+ api_path = "/v3/seals/org-seal?orgId={}&sealId={}".format(orgId, sealId) # 拼接请求路径
|
|
|
+ print(api_path)
|
|
|
+ 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 org_sealurl():
|
|
|
+ """
|
|
|
+ 获取创建机构印章页面链接
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+
|
|
|
+ "orgId": "0c5bd492***48bfbf",
|
|
|
+ "transactorPsnId": "c7e00294***10541e7",
|
|
|
+ "customBizNum": "这是一串开发者内部系统自定义的编号",
|
|
|
+ "sealName": "这是个预定义的企业印章名称",
|
|
|
+ "sealColor": "RED",
|
|
|
+ "redirectUrl": "http://www.xxx.cn/",
|
|
|
+ "uneditableFields": ["sealName", "sealColor"]
|
|
|
+
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seal-create-url" # 拼接请求路径
|
|
|
+ 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 manage_sealurl():
|
|
|
+ """
|
|
|
+ 获取管理机构印章页面链接
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 构建请求body体
|
|
|
+
|
|
|
+ body = {
|
|
|
+
|
|
|
+ "orgId": "0c5bd492**8bfbf",
|
|
|
+ "transactorPsnId": "c7e00294729***10541e7"
|
|
|
+
|
|
|
+ }
|
|
|
+ api_path = "/v3/seals/org-seals-manage-url" # 拼接请求路径
|
|
|
+ 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
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ # create_templateseals() # 创建机构模板印章
|
|
|
+ # create_orgimage() # 创建企业图片印章
|
|
|
+ # internal_auth() # 内部成员授权
|
|
|
+ external_auth() # 跨企业授权
|
|
|
+ auth_delete() # 解除印章授权
|
|
|
+ authorization() # 查询授权书签署链接
|
|
|
+ internal_detail() # 查询对内部成员授权详情
|
|
|
+ external_detail() # 查询对外部企业授权详情
|
|
|
+ reauthorization() # 修改印章授权期限
|
|
|
+ own_seal() # 查询企业内部印章
|
|
|
+ authorized_seal() # 查询被外部企业授权印章
|
|
|
+ info_seal() # 查询指定印章详情(机构)
|
|
|
+ default_seal() # 设置机构默认印章
|
|
|
+ orgseals_delete() # 设置机构默认印章
|
|
|
+ org_sealurl() # 获取创建机构印章页面链接
|
|
|
+ manage_sealurl() # 获取管理机构印章页面链接
|