| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import requests
- import json
- from common.esigntool.esign_config import Config
- from common.esigntool.esign_algorithm import buildSignJsonHeader
- import time
- from datetime import datetime
- config = Config()
- def get_auth_flow_id():
- """获取机构认证&授权页面链接"""
- api_path = "/v3/org-auth-url"
- method = "POST"
- body = {
- "clientType": "ALL",
- "redirectConfig": {
- "redirectUrl": "https://www.baidu.com"
- },
- "orgAuthConfig": {
- "orgId": config.ordid,
- }
- }
- # 签名使用原始字典,内部会统一 json.dumps(去空格),再用完全一致的字符串发送
- json_headers = buildSignJsonHeader(config.appId, config.scert, method, api_path, body=body)
- body_json = json.dumps(body, separators=(",", ":"), ensure_ascii=False)
- resp = requests.request(method, config.host + api_path, data=body_json, headers=json_headers)
- print(resp.text)
- return resp.text
- # get_auth_flow_id()
- def get_template_detail():
- """查询合同模板中控件详情"""
- api_path = f"/v3/doc-templates/{config.templates_id}"
- method = "GET"
- json_headers = buildSignJsonHeader(config.appId, config.scert, method, api_path)
- resp = requests.request(method, config.host + api_path, headers=json_headers)
- print(resp.text)
- def fill_in_template(name):
- """填写模板生成文件"""
- api_path = "/v3/files/create-by-doc-template"
- method = "POST"
- body = {
- "docTemplateId": config.templates_id,
- "fileName": "U店在这-商户入驻协议",
- "components": [
- {
- "componentKey": "alien_name",
- "componentValue": "爱丽恩严(大连)商务科技有限公司"
- },
- {
- "componentKey": "store_name",
- "componentValue": name
- },
- {
- "componentKey": "date",
- "componentValue": datetime.now().strftime("%Y年%m月%d日")
- }
- ]
- }
- json_headers = buildSignJsonHeader(config.appId, config.scert, method, api_path, body=body)
- body_json = json.dumps(body, separators=(",", ":"), ensure_ascii=False)
- resp = requests.request(method, config.host + api_path, data=body_json, headers=json_headers)
- print(resp.text)
- return resp.text
- fill_in_template("哈哈")
|