com/developers/companyApis/startFlows/CreateFlow try: # 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 # 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 # 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 cred = credential.Credential(secret_id, secret_key) # 实例化一个http选项,可选的,没有特殊需求可以跳过 httpProfile = HttpProfile() httpProfile.endpoint = endpoint # 实例化一个client选项,可选的,没有特殊需求可以跳过 clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile # 实例化要请求产品的client对象,clientProfile是可选的 client = ess_client.EssClient(cred, "", clientProfile) # 实例化一个请求对象,每个接口都会对应一个request对象 req = models.CreateFlowRequest() params = { "Operator": { "UserId": operator_id }, "FlowName": flow_name, "FlowType": flow_type, "Approvers": approvers, } req.from_json_string(json.dumps(params)) # 返回的resp是一个DescribeFlowTemplatesResponse的实例,与请求对象对应 resp = client.CreateFlow(req) # 输出json格式的字符串回包 # print(resp.to_json_string()) except TencentCloudSDKException as err: print(err) resp = {} return resp def test_create_document(): class lensman: phone = '18888888888' identity_card_name = '张三' identity_card_number = '460005199605144313' flow_id = 'yDCHHUU08ki1zsUY6XuiSQfzpNaT4BXE' file_id = 'yDCHHUU08q2s90UGmXutvE1Vf4nBGGYu' form_fields = [ { "ComponentId": "ComponentId_0", "ComponentValue": lensman.identity_card_name }, { "ComponentId": "ComponentId_1", "ComponentValue": lensman.identity_card_number, }, { "ComponentId": "ComponentId_2", "ComponentValue": "100", }, { "ComponentId": "ComponentId_3", "ComponentValue": "壹佰", }, { "ComponentId": "ComponentId_37", "ComponentValue": file_id, } ] return create_document(flow_id=flow_id, form_fields=form_fields) def create_document(flow_id=None, form_fields=None): # https://qian.tencent.com/developers/companyApis/startFlows/CreateDocument/ try: # 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 # 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 # 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 cred = credential.Credential(secret_id, secret_key) # 实例化一个http选项,可选的,没有特殊需求可以跳过 httpProfile = HttpProfile() httpProfile.endpoint = endpoint # 实例化一个client选项,可选的,没有特殊需求可以跳过 clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile # 实例化要请求产品的client对象,clientProfile是可选的 client = ess_client.EssClient(cred, "", clientProfile) # 实例化一个请求对象,每个接口都会对应一个request对象 req = models.CreateDocumentRequest() params = { "Operator": { "UserId": operator_id }, "TemplateId": template_id, "FlowId": flow_id, "FormFields": form_fields, } req.from_json_string(json.dumps(params)) # 返回的resp是一个DescribeFlowTemplatesResponse的实例,与请求对象对应 resp = client.CreateDocument(req) # 输出json格式的字符串回包 # print(resp.to_json_string()) except TencentCloudSDKException as err: print(err) resp = {} return resp def test_start_flow(): flow_id = 'yDCHHUU08ki1zsUY6XuiSQfzpNaT4BXE' return start_flow(flow_id=flow_id) def start_flow(flow_id=None): # https://qian.tencent.com/developers/companyApis/startFlows/StartFlow/ try: # 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 # 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 # 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 cred = credential.Credential(secret_id, secret_key) # 实例化一个http选项,可选的,没有特殊需求可以跳过 httpProfile = HttpProfile() httpProfile.endpoint = endpoint # 实例化一个client选项,可选的,没有特殊需求可以跳过 clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile # 实例化要请求产品的client对象,clientProfile是可选的 client = ess_client.EssClient(cred, "", clientProfile) # 实例化一个请求对象,每个接口都会对应一个request对象 req = models.StartFlowRequest() params = { "Operator": { "UserId": operator_id }, "FlowId": flow_id, } req.from_json_string(json.dumps(params)) # 返回的resp是一个DescribeFlowTemplatesResponse的实例,与请求对象对应 resp = client.StartFlow(req) # 输出json格式的字符串回包 # print(resp.to_json_string()) except TencentCloudSDKException as err: print(err) resp = {} return resp def test_create_scheme_url(): class lensman: phone = '18888888888' identity_card_name = '张三' identity_card_number = '460005199605144313' flow_id = 'yDCHHUU08ki1zsUY6XuiSQfzpNaT4BXE' return create_scheme_url(flow_id=flow_id, name=lensman.identity_card_name, mobile=lensman.phone, card_type='ID_CARD', card_number=lensman.identity_card_number) def create_scheme_url(flow_id=None, name=None, mobile=None, card_type='ID_CARD', card_number=None): # https://qian.tencent.com/developers/companyApis/startFlows/CreateSchemeUrl try: # 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 # 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 # 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 cred = credential.Credential(secret_id, secret_key) # 实例化一个http选项,可选的,没有特殊需求可以跳过 httpProfile = HttpProfile() httpProfile.endpoint = endpoint # 实例化一个client选项,可选的,没有特殊需求可以跳过 clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile # 实例化要请求产品的client对象,clientProfile是可选的 client = ess_client.EssClient(cred, "", clientProfile) # 实例化一个请求对象,每个接口都会对应一个request对象 req = models.CreateSchemeUrlRequest() params = { "Operator": { "UserId": operator_id }, "FlowId": flow_id, "Name": name, "Mobile": mobile, "IdCardType": card_type, "IdCardNumber": card_number, "EndPoint": "APP", "PathType": 1, # 腾讯电子签小程序流程合同的详情页 "AutoJumpBack": True, # 签署完成会自动跳转回来 } req.from_json_string(json.dumps(params)) # 返回的resp是一个DescribeFlowTemplatesResponse的实例,与请求对象对应 resp = client.CreateSchemeUrl(req) # 输出json格式的字符串回包 # print(resp.to_json_string()) except TencentCloudSDKException as err: print(err) resp = {} return resp def decode_aes256(data, encryption_key): iv = encryption_key[0:16] aes = AES.new(encryption_key, AES.MODE_CBC, iv) d = aes.decrypt(data) unpad = lambda s: s[0:-ord(d[-1:])] return unpad(d) def test_decode(): # https://qian.tencent.com/developers/company/callback_types_v2 data = "62KE4r5Wz0yHzEpMOwVRbM1KV0pPjj+cmJkT+i65MMscgfHAdNP+9K0nV/fFw1xriwi08APc/wM0mHprE43Hc91VPhRDnu2Wn0+bjzgjmy/FgZKZATR9oquy0/BCWu4C77AjkpkoU1/E7gGLr8M9u9t7zbS4AkkGK5xL5TtwI0sS+CMygmyV7bRjxebMycI52U3QJiwDRIPxFO+7yqeXYXV9AQrRskpCDBNFGW72bh+Ixw9dtX00kWcwVQ93V+mayrvdQ8oGSsL32m72kbBfahsIvIxSYSdDAEeTyokqKGfaLWD27vm55QG218IFKEsOJFDGdqCF+IBcM/+rOFeOrewvP5ehIO2KjFBecTDn0RQTlIiokXIQ4zJKvu6njePFRFoFCZjd4oiEIVn/OBw+rjXml3qwgVBQjPRtYdvDJFNENlVjlkVVmLWeS8MIdqsFWhm6Sa7O8X57mwc0cLJ22mGbyVEzNTFqeFJ/mkueW0leLcoZdjv/+IxZusqa1cpfwzkZhwi5rY6kJffNkkrxIc6OeRvpU4ECgBe/b+kxX+ObC0z9u7nzoZAOHx4akYviyIU5B1romjdfHQ/wDr5udm4Rl4NBhU/6V06Rvaadw0Ta9oBkZHGNxFWv32MnL7fVA0zVNOFDP8n+kaQiNGFAXLF4F5oIItYc5+Gp/IxfkltEki7ni7LztViE7b/ZiKSM+gzQn6fLsJ/dlUoZmh141Y0V/GPpsbxBOnWCjBZdNkLTKxdKCMScLCTysJxv7l6Swff8nAEurbzx1tvyhJAvUDnIaLyP8pRPRFq8p0xm3ZVpOo9k7A952XxVHSs40g4sr/Dihkn60aVhGtKK9DueCzn8P3cWG4TYc03M1hNlPfF+UAfnvQ1ZYAMKT/XPLqYtgRFpRkK96YfVecIrfUe9MjWl0/g4hYCAAOJurFoeGwkJiyQ8Q7DCI5EaHa3s/vI621yQyytC6D2u86RiDJxMW0PdvkUfayT7iPwC83EsfEzpQXr0yeSCQCSBgNByEuCNnZl8LAhYl05Y9+bgCzSPt6EUvmaXclYL+/EPrEmi+hzIdXUwBfhXgICT8MteJgMSgmJM2FjjGxy6uZtfHKRIzf1wk6OORPkPJtMgjlMtMs6VFC62EEeo5Xy2v1S95WT/WQ0tnGR8KjbNnmjNSRyD8VtS2mjlLXaK0xRb71YGt57O19YxQQ3R/Hq9zGqOjG+Agdl+pcvh47RlF8o3CnlU7Q==" encryption_key = 'TencentEssEncryptTestKey12345678' return callback_decode(data, encryption_key) def callback_decode(data, encryption_key=None): # 此处传入密文,如果接收到的数据是{"encrypt":"base64后的密文"} # data = 'base64后的密文' data = base64.b64decode(data) encryption_key = encryption_key or callback_secret_key # encryption_key = bytes(encryption_key or callback_secret_key, encoding="utf8") # 此处传入CallbackUrlKey e = decode_aes256(data, encryption_key) # print(type(e)) # print(e) # print(str(e, encoding="utf8")) return json.loads(e) def test_describe_file_urls(): # { # "TotalCount": 1, # "FileUrls": [ # { # "Url": "https://file.ess.tencent.cn/file/FLOW/yDCHQUU0q7lli4UxZZqK9EJQBXolGmKl/0/0.PDF?hkey=2224d95a960e5bc7e6e3686cff314349ca93867dbd0b1eca01ba63991c8bd8e9c479977410d668b7b3d5bf14af059f969ce4644cf43a7cb6395601a042cadd33a56be20d1643070aa660af450d0ee0b6e30758030e2c0cbd2276bd1d4f05c818", # "Option": "[\"595.30,841.90\",\"-1\"]" # } # ], # "RequestId": "e9381020-c673-4ea6-b051-3a64b0e8a821" # } business_id = 'yDCHQUU0q7lli4UxZZqK9EJQBXolGmKl' return describe_file_urls(business_id=business_id) def describe_file_urls(business_type='FLOW', business_id=None, business_ids=None, file_type='PDF', url_ttl=86400): # https://qian.tencent.com/developers/companyApis/templatesAndFiles/DescribeFileUrls/ try: # 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 # 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 # 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 cred = credential.Credential(secret_id, secret_key) # 实例化一个http选项,可选的,没有特殊需求可以跳过 httpProfile = HttpProfile() httpProfile.endpoint = endpoint # 实例化一个client选项,可选的,没有特殊需求可以跳过 clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile # 实例化要请求产品的client对象,clientProfile是可选的 client = ess_client.EssClient(cred, "", clientProfile) # 实例化一个请求对象,每个接口都会对应一个request对象 req = models.DescribeFileUrlsRequest() business_ids = business_ids or [business_id] params = { "Operator": { "UserId": operator_id }, "BusinessType": business_type, "BusinessIds": business_ids, "FileType": file_type, "UrlTtl": url_ttl, } req.from_json_string(json.dumps(params)) # 返回的resp是一个DescribeFlowTemplatesResponse的实例,与请求对象对应 resp = client.DescribeFileUrls(req) # 输出json格式的字符串回包 # print(resp.to_json_string()) except TencentCloudSDKException as err: print(err) resp = {} return resp Kodo/kodo - Gogs: Go Git Service

1 次代碼提交 (04bd86d6da09e3b8ce1b227020e87835ff9b9b4a)

作者 SHA1 備註 提交日期
  Brightcells 246a9ff4b8 Change to 'from utils.redis.connect import r' 9 年之前