est对象 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 adminSystem - Gogs: Go Git Service

Brak opisu

cancel.js 3.6KB

    "use strict"; module.exports = function(Promise, PromiseArray, apiRejection, debug) { var util = require("./util"); var tryCatch = util.tryCatch; var errorObj = util.errorObj; var async = Promise._async; Promise.prototype["break"] = Promise.prototype.cancel = function() { if (!debug.cancellation()) return this._warn("cancellation is disabled"); var promise = this; var child = promise; while (promise._isCancellable()) { if (!promise._cancelBy(child)) { if (child._isFollowing()) { child._followee().cancel(); } else { child._cancelBranched(); } break; } var parent = promise._cancellationParent; if (parent == null || !parent._isCancellable()) { if (promise._isFollowing()) { promise._followee().cancel(); } else { promise._cancelBranched(); } break; } else { if (promise._isFollowing()) promise._followee().cancel(); promise._setWillBeCancelled(); child = promise; promise = parent; } } }; Promise.prototype._branchHasCancelled = function() { this._branchesRemainingToCancel--; }; Promise.prototype._enoughBranchesHaveCancelled = function() { return this._branchesRemainingToCancel === undefined || this._branchesRemainingToCancel <= 0; }; Promise.prototype._cancelBy = function(canceller) { if (canceller === this) { this._branchesRemainingToCancel = 0; this._invokeOnCancel(); return true; } else { this._branchHasCancelled(); if (this._enoughBranchesHaveCancelled()) { this._invokeOnCancel(); return true; } } return false; }; Promise.prototype._cancelBranched = function() { if (this._enoughBranchesHaveCancelled()) { this._cancel(); } }; Promise.prototype._cancel = function() { if (!this._isCancellable()) return; this._setCancelled(); async.invoke(this._cancelPromises, this, undefined); }; Promise.prototype._cancelPromises = function() { if (this._length() > 0) this._settlePromises(); }; Promise.prototype._unsetOnCancel = function() { this._onCancelField = undefined; }; Promise.prototype._isCancellable = function() { return this.isPending() && !this._isCancelled(); }; Promise.prototype.isCancellable = function() { return this.isPending() && !this.isCancelled(); }; Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) { if (util.isArray(onCancelCallback)) { for (var i = 0; i < onCancelCallback.length; ++i) { this._doInvokeOnCancel(onCancelCallback[i], internalOnly); } } else if (onCancelCallback !== undefined) { if (typeof onCancelCallback === "function") { if (!internalOnly) { var e = tryCatch(onCancelCallback).call(this._boundValue()); if (e === errorObj) { this._attachExtraTrace(e.e); async.throwLater(e.e); } } } else { onCancelCallback._resultCancelled(this); } } }; Promise.prototype._invokeOnCancel = function() { var onCancelCallback = this._onCancel(); this._unsetOnCancel(); async.invoke(this._doInvokeOnCancel, this, onCancelCallback); }; Promise.prototype._invokeInternalOnCancel = function() { if (this._isCancellable()) { this._doInvokeOnCancel(this._onCancel(), true); this._unsetOnCancel(); } }; Promise.prototype._resultCancelled = function() { this.cancel(); }; };