cloudauth-20200618/main.tea (842 lines of code) (raw):

/** * */ import Util; import OSS; import OpenPlatform; import OSSUtil; import FileForm; import OpenApi; import OpenApiUtil; import EndpointUtil; extends OpenApi; init(config: OpenApi.Config){ super(config); @endpointRule = 'central'; checkConfig(config); @endpoint = getEndpoint('cloudauth', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint); } function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{ if (!Util.empty(endpoint)) { return endpoint; } if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) { return endpointMap[regionId]; } return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix); } model ContrastSmartVerifyRequest { certName?: string(name='CertName'), certNo?: string(name='CertNo'), certType?: string(name='CertType'), facePicFile?: string(name='FacePicFile'), facePicString?: string(name='FacePicString'), facePicUrl?: string(name='FacePicUrl'), ip?: string(name='Ip'), mobile?: string(name='Mobile'), mode?: string(name='Mode'), outerOrderNo?: string(name='OuterOrderNo'), sceneId?: long(name='SceneId'), userId?: string(name='UserId'), } model ContrastSmartVerifyAdvanceRequest { certName?: string(name='CertName'), certNo?: string(name='CertNo'), certType?: string(name='CertType'), facePicFileObject?: readable(name='FacePicFile'), facePicString?: string(name='FacePicString'), facePicUrl?: string(name='FacePicUrl'), ip?: string(name='Ip'), mobile?: string(name='Mobile'), mode?: string(name='Mode'), outerOrderNo?: string(name='OuterOrderNo'), sceneId?: long(name='SceneId'), userId?: string(name='UserId'), } model ContrastSmartVerifyResponseBody = { code?: string(name='Code'), message?: string(name='Message'), requestId?: string(name='RequestId'), resultObject?: { certifyId?: string(name='CertifyId'), passed?: string(name='Passed'), riskInfo?: string(name='RiskInfo'), subCode?: string(name='SubCode'), verifyInfo?: string(name='VerifyInfo'), }(name='ResultObject'), } model ContrastSmartVerifyResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: ContrastSmartVerifyResponseBody(name='body'), } async function contrastSmartVerifyWithOptions(request: ContrastSmartVerifyRequest, runtime: Util.RuntimeOptions): ContrastSmartVerifyResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.certName)) { body['CertName'] = request.certName; } if (!Util.isUnset(request.certNo)) { body['CertNo'] = request.certNo; } if (!Util.isUnset(request.certType)) { body['CertType'] = request.certType; } if (!Util.isUnset(request.facePicFile)) { body['FacePicFile'] = request.facePicFile; } if (!Util.isUnset(request.facePicString)) { body['FacePicString'] = request.facePicString; } if (!Util.isUnset(request.facePicUrl)) { body['FacePicUrl'] = request.facePicUrl; } if (!Util.isUnset(request.ip)) { body['Ip'] = request.ip; } if (!Util.isUnset(request.mobile)) { body['Mobile'] = request.mobile; } if (!Util.isUnset(request.mode)) { body['Mode'] = request.mode; } if (!Util.isUnset(request.outerOrderNo)) { body['OuterOrderNo'] = request.outerOrderNo; } if (!Util.isUnset(request.sceneId)) { body['SceneId'] = request.sceneId; } if (!Util.isUnset(request.userId)) { body['UserId'] = request.userId; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'ContrastSmartVerify', version = '2020-06-18', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function contrastSmartVerify(request: ContrastSmartVerifyRequest): ContrastSmartVerifyResponse { var runtime = new Util.RuntimeOptions{}; return contrastSmartVerifyWithOptions(request, runtime); } async function contrastSmartVerifyAdvance(request: ContrastSmartVerifyAdvanceRequest, runtime: Util.RuntimeOptions): ContrastSmartVerifyResponse { // Step 0: init client var accessKeyId = @credential.getAccessKeyId(); var accessKeySecret = @credential.getAccessKeySecret(); var securityToken = @credential.getSecurityToken(); var credentialType = @credential.getType(); var openPlatformEndpoint = @openPlatformEndpoint; if(Util.isUnset(openPlatformEndpoint)) { openPlatformEndpoint ='openplatform.aliyuncs.com'; } if(Util.isUnset(credentialType)) { credentialType ='access_key'; } var authConfig = new OpenApi.Config{ accessKeyId = accessKeyId, accessKeySecret = accessKeySecret, securityToken = securityToken, type = credentialType, endpoint = openPlatformEndpoint, protocol = @protocol, regionId = @regionId, }; var authClient = new OpenPlatform(authConfig); var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{ product = 'Cloudauth', regionId = @regionId, }; var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{}; var ossConfig = new OSS.Config{ accessKeySecret = accessKeySecret, type = 'access_key', protocol = @protocol, regionId = @regionId, }; var ossClient : OSS = null; var fileObj = new FileForm.FileField{}; var ossHeader = new OSS.PostObjectRequest.header{}; var uploadRequest = new OSS.PostObjectRequest{}; var ossRuntime = new OSSUtil.RuntimeOptions{}; OpenApiUtil.convert(runtime, ossRuntime); var contrastSmartVerifyReq = new ContrastSmartVerifyRequest{}; OpenApiUtil.convert(request, contrastSmartVerifyReq); if(!Util.isUnset(request.facePicFileObject)) { authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime); ossConfig.accessKeyId = authResponse.body.accessKeyId; ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType); ossClient = new OSS(ossConfig); fileObj = new FileForm.FileField{ filename = authResponse.body.objectKey, content = request.facePicFileObject, contentType = '', }; ossHeader = new OSS.PostObjectRequest.header{ accessKeyId = authResponse.body.accessKeyId, policy = authResponse.body.encodedPolicy, signature = authResponse.body.signature, key = authResponse.body.objectKey, file = fileObj, successActionStatus = '201', }; uploadRequest = new OSS.PostObjectRequest{ bucketName = authResponse.body.bucket, header = ossHeader, }; ossClient.postObject(uploadRequest, ossRuntime); contrastSmartVerifyReq.facePicFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var contrastSmartVerifyResp = contrastSmartVerifyWithOptions(contrastSmartVerifyReq, runtime); return contrastSmartVerifyResp; } model DescribeSmartVerifyRequest { certifyId?: string(name='CertifyId', example='91707dc296d469ad38e4c5efa6a0xxxx'), pictureReturnType?: string(name='PictureReturnType'), sceneId?: long(name='SceneId', example='100000xxxx'), } model DescribeSmartVerifyResponseBody = { code?: string(name='Code', example='200'), message?: string(name='Message', example='success'), requestId?: string(name='RequestId', example='130A2C10-B9EE-4D84-88E3-5384FF039795'), resultObject?: { materialInfo?: string(name='MaterialInfo', example='{"riskInfo": { "score": 35,"tags": "rm0114"} }'), passed?: string(name='Passed', example='T'), passedScore?: float(name='PassedScore', example='80.2'), subCode?: string(name='SubCode', example='200'), }(name='ResultObject'), } model DescribeSmartVerifyResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DescribeSmartVerifyResponseBody(name='body'), } async function describeSmartVerifyWithOptions(request: DescribeSmartVerifyRequest, runtime: Util.RuntimeOptions): DescribeSmartVerifyResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.certifyId)) { body['CertifyId'] = request.certifyId; } if (!Util.isUnset(request.pictureReturnType)) { body['PictureReturnType'] = request.pictureReturnType; } if (!Util.isUnset(request.sceneId)) { body['SceneId'] = request.sceneId; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'DescribeSmartVerify', version = '2020-06-18', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function describeSmartVerify(request: DescribeSmartVerifyRequest): DescribeSmartVerifyResponse { var runtime = new Util.RuntimeOptions{}; return describeSmartVerifyWithOptions(request, runtime); } model DescribeSmsDetailRequest { bizId?: string(name='BizId', example='qwer^xxxxx'), currentPage?: int32(name='CurrentPage', example='1'), errorCode?: string(name='ErrorCode', example='SP_UNKNOWN_ERROR'), mobile?: string(name='Mobile', example='150000xxxx'), outerOrderNo?: string(name='OuterOrderNo', example='qwertyuiopasdfghjklzxcvbnmqxxxx'), pageSize?: int32(name='PageSize', example='10'), sendDate?: string(name='SendDate', example='20210428'), sendStatus?: string(name='SendStatus', example='FAILED'), signName?: string(name='SignName'), templateCode?: string(name='TemplateCode', example='SMS_0000'), } model DescribeSmsDetailResponseBody = { code?: string(name='Code', example='200'), currentPage?: int32(name='CurrentPage', example='1'), items?: [ { bizId?: string(name='BizId', example='qwer^xxxxxxxx'), content?: string(name='Content'), errorCode?: string(name='ErrorCode', example='DELIVERED'), errorMessage?: string(name='ErrorMessage'), mobile?: string(name='Mobile', example='1500000xxxx'), outerOrderNo?: string(name='OuterOrderNo', example='qwertyuiopasdfghjklzxcvbnmqxxxx'), receiveDate?: string(name='ReceiveDate', example='2021-04-28 12:00:00'), sendDate?: string(name='SendDate', example='2021-04-28 12:00:00'), sendStatus?: string(name='SendStatus', example='SUCCESS'), signName?: string(name='SignName'), smsSize?: int32(name='SmsSize', example='1'), taskDate?: string(name='TaskDate', example='2021-04-28 12:00:00'), templateCode?: string(name='TemplateCode', example='SMS_0000'), } ](name='Items'), message?: string(name='Message', example='success'), pageSize?: int32(name='PageSize', example='10'), requestId?: string(name='RequestId', example='5A6229C0-E156-48E4-B6EC-0F528BDF60D2'), totalItem?: int32(name='TotalItem', example='1'), totalPage?: int32(name='TotalPage', example='1'), } model DescribeSmsDetailResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: DescribeSmsDetailResponseBody(name='body'), } async function describeSmsDetailWithOptions(request: DescribeSmsDetailRequest, runtime: Util.RuntimeOptions): DescribeSmsDetailResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.bizId)) { body['BizId'] = request.bizId; } if (!Util.isUnset(request.currentPage)) { body['CurrentPage'] = request.currentPage; } if (!Util.isUnset(request.errorCode)) { body['ErrorCode'] = request.errorCode; } if (!Util.isUnset(request.mobile)) { body['Mobile'] = request.mobile; } if (!Util.isUnset(request.outerOrderNo)) { body['OuterOrderNo'] = request.outerOrderNo; } if (!Util.isUnset(request.pageSize)) { body['PageSize'] = request.pageSize; } if (!Util.isUnset(request.sendDate)) { body['SendDate'] = request.sendDate; } if (!Util.isUnset(request.sendStatus)) { body['SendStatus'] = request.sendStatus; } if (!Util.isUnset(request.signName)) { body['SignName'] = request.signName; } if (!Util.isUnset(request.templateCode)) { body['TemplateCode'] = request.templateCode; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'DescribeSmsDetail', version = '2020-06-18', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function describeSmsDetail(request: DescribeSmsDetailRequest): DescribeSmsDetailResponse { var runtime = new Util.RuntimeOptions{}; return describeSmsDetailWithOptions(request, runtime); } model ElementSmartVerifyRequest { certFile?: string(name='CertFile'), certName?: string(name='CertName'), certNationalEmblemUrl?: string(name='CertNationalEmblemUrl'), certNo?: string(name='CertNo'), certType?: string(name='CertType'), certUrl?: string(name='CertUrl'), mode?: string(name='Mode'), outerOrderNo?: string(name='OuterOrderNo'), sceneId?: long(name='SceneId'), } model ElementSmartVerifyAdvanceRequest { certFileObject?: readable(name='CertFile'), certName?: string(name='CertName'), certNationalEmblemUrl?: string(name='CertNationalEmblemUrl'), certNo?: string(name='CertNo'), certType?: string(name='CertType'), certUrl?: string(name='CertUrl'), mode?: string(name='Mode'), outerOrderNo?: string(name='OuterOrderNo'), sceneId?: long(name='SceneId'), } model ElementSmartVerifyResponseBody = { code?: string(name='Code'), message?: string(name='Message'), requestId?: string(name='RequestId'), resultObject?: { certifyId?: string(name='CertifyId'), materialInfo?: string(name='MaterialInfo'), passed?: string(name='Passed'), subCode?: string(name='SubCode'), }(name='ResultObject'), } model ElementSmartVerifyResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: ElementSmartVerifyResponseBody(name='body'), } async function elementSmartVerifyWithOptions(request: ElementSmartVerifyRequest, runtime: Util.RuntimeOptions): ElementSmartVerifyResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.certFile)) { body['CertFile'] = request.certFile; } if (!Util.isUnset(request.certName)) { body['CertName'] = request.certName; } if (!Util.isUnset(request.certNationalEmblemUrl)) { body['CertNationalEmblemUrl'] = request.certNationalEmblemUrl; } if (!Util.isUnset(request.certNo)) { body['CertNo'] = request.certNo; } if (!Util.isUnset(request.certType)) { body['CertType'] = request.certType; } if (!Util.isUnset(request.certUrl)) { body['CertUrl'] = request.certUrl; } if (!Util.isUnset(request.mode)) { body['Mode'] = request.mode; } if (!Util.isUnset(request.outerOrderNo)) { body['OuterOrderNo'] = request.outerOrderNo; } if (!Util.isUnset(request.sceneId)) { body['SceneId'] = request.sceneId; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'ElementSmartVerify', version = '2020-06-18', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function elementSmartVerify(request: ElementSmartVerifyRequest): ElementSmartVerifyResponse { var runtime = new Util.RuntimeOptions{}; return elementSmartVerifyWithOptions(request, runtime); } async function elementSmartVerifyAdvance(request: ElementSmartVerifyAdvanceRequest, runtime: Util.RuntimeOptions): ElementSmartVerifyResponse { // Step 0: init client var accessKeyId = @credential.getAccessKeyId(); var accessKeySecret = @credential.getAccessKeySecret(); var securityToken = @credential.getSecurityToken(); var credentialType = @credential.getType(); var openPlatformEndpoint = @openPlatformEndpoint; if(Util.isUnset(openPlatformEndpoint)) { openPlatformEndpoint ='openplatform.aliyuncs.com'; } if(Util.isUnset(credentialType)) { credentialType ='access_key'; } var authConfig = new OpenApi.Config{ accessKeyId = accessKeyId, accessKeySecret = accessKeySecret, securityToken = securityToken, type = credentialType, endpoint = openPlatformEndpoint, protocol = @protocol, regionId = @regionId, }; var authClient = new OpenPlatform(authConfig); var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{ product = 'Cloudauth', regionId = @regionId, }; var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{}; var ossConfig = new OSS.Config{ accessKeySecret = accessKeySecret, type = 'access_key', protocol = @protocol, regionId = @regionId, }; var ossClient : OSS = null; var fileObj = new FileForm.FileField{}; var ossHeader = new OSS.PostObjectRequest.header{}; var uploadRequest = new OSS.PostObjectRequest{}; var ossRuntime = new OSSUtil.RuntimeOptions{}; OpenApiUtil.convert(runtime, ossRuntime); var elementSmartVerifyReq = new ElementSmartVerifyRequest{}; OpenApiUtil.convert(request, elementSmartVerifyReq); if(!Util.isUnset(request.certFileObject)) { authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime); ossConfig.accessKeyId = authResponse.body.accessKeyId; ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType); ossClient = new OSS(ossConfig); fileObj = new FileForm.FileField{ filename = authResponse.body.objectKey, content = request.certFileObject, contentType = '', }; ossHeader = new OSS.PostObjectRequest.header{ accessKeyId = authResponse.body.accessKeyId, policy = authResponse.body.encodedPolicy, signature = authResponse.body.signature, key = authResponse.body.objectKey, file = fileObj, successActionStatus = '201', }; uploadRequest = new OSS.PostObjectRequest{ bucketName = authResponse.body.bucket, header = ossHeader, }; ossClient.postObject(uploadRequest, ossRuntime); elementSmartVerifyReq.certFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var elementSmartVerifyResp = elementSmartVerifyWithOptions(elementSmartVerifyReq, runtime); return elementSmartVerifyResp; } model InitSmartVerifyRequest { callbackToken?: string(name='CallbackToken', example='NMjvQanQgplBSaEI0sL86WnQplB'), callbackUrl?: string(name='CallbackUrl', example='https://www.aliyun.com'), certName?: string(name='CertName'), certNo?: string(name='CertNo', example='330103xxxxxxxxxxxx'), certType?: string(name='CertType', example='IDENTITY_CARD'), certifyId?: string(name='CertifyId'), facePictureBase64?: string(name='FacePictureBase64'), facePictureUrl?: string(name='FacePictureUrl'), idName?: string(name='IdName'), idNo?: string(name='IdNo'), ip?: string(name='Ip', example='114.xxx.xxx.xxx'), metaInfo?: string(name='MetaInfo', example='{"zimVer":"3.0.0","appVersion": "1","bioMetaInfo": "4.1.0:11501568,0","appName": "com.aliyun.antcloudauth","deviceType":"ios","osVersion": "iOS 10.3.2","apdidToken": "","deviceModel": "iPhone9,1"}'), mobile?: string(name='Mobile', example='130xxxxxxxx'), mode?: string(name='Mode', example='ACCOUNT_SAFE'), ocr?: string(name='Ocr'), ossBucketName?: string(name='OssBucketName'), ossObjectName?: string(name='OssObjectName'), outerOrderNo?: string(name='OuterOrderNo', example='e0c34a77f5ac40a5aa5e6ed20c35xxxx'), sceneId?: long(name='SceneId', example='100000xxxx'), userId?: string(name='UserId', example='12345xxxx'), } model InitSmartVerifyResponseBody = { code?: string(name='Code', example='200'), message?: string(name='Message', example='success'), requestId?: string(name='RequestId', example='0F591A7A-98B7-58D8-B9AC-3D71703AEE57'), resultObject?: { certifyId?: string(name='CertifyId', example='91707dc296d469ad38e4c5efa6a0xxxx'), }(name='ResultObject'), } model InitSmartVerifyResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: InitSmartVerifyResponseBody(name='body'), } async function initSmartVerifyWithOptions(request: InitSmartVerifyRequest, runtime: Util.RuntimeOptions): InitSmartVerifyResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.callbackToken)) { body['CallbackToken'] = request.callbackToken; } if (!Util.isUnset(request.callbackUrl)) { body['CallbackUrl'] = request.callbackUrl; } if (!Util.isUnset(request.certName)) { body['CertName'] = request.certName; } if (!Util.isUnset(request.certNo)) { body['CertNo'] = request.certNo; } if (!Util.isUnset(request.certType)) { body['CertType'] = request.certType; } if (!Util.isUnset(request.certifyId)) { body['CertifyId'] = request.certifyId; } if (!Util.isUnset(request.facePictureBase64)) { body['FacePictureBase64'] = request.facePictureBase64; } if (!Util.isUnset(request.facePictureUrl)) { body['FacePictureUrl'] = request.facePictureUrl; } if (!Util.isUnset(request.idName)) { body['IdName'] = request.idName; } if (!Util.isUnset(request.idNo)) { body['IdNo'] = request.idNo; } if (!Util.isUnset(request.ip)) { body['Ip'] = request.ip; } if (!Util.isUnset(request.metaInfo)) { body['MetaInfo'] = request.metaInfo; } if (!Util.isUnset(request.mobile)) { body['Mobile'] = request.mobile; } if (!Util.isUnset(request.mode)) { body['Mode'] = request.mode; } if (!Util.isUnset(request.ocr)) { body['Ocr'] = request.ocr; } if (!Util.isUnset(request.ossBucketName)) { body['OssBucketName'] = request.ossBucketName; } if (!Util.isUnset(request.ossObjectName)) { body['OssObjectName'] = request.ossObjectName; } if (!Util.isUnset(request.outerOrderNo)) { body['OuterOrderNo'] = request.outerOrderNo; } if (!Util.isUnset(request.sceneId)) { body['SceneId'] = request.sceneId; } if (!Util.isUnset(request.userId)) { body['UserId'] = request.userId; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'InitSmartVerify', version = '2020-06-18', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function initSmartVerify(request: InitSmartVerifyRequest): InitSmartVerifyResponse { var runtime = new Util.RuntimeOptions{}; return initSmartVerifyWithOptions(request, runtime); } model SendSmsRequest { mobile?: string(name='Mobile', example='861500000****'), outerOrderNo?: string(name='OuterOrderNo', example='abcdefghfdfsdffafdaqwertyuioxxxx'), signName?: string(name='SignName'), templateCode?: string(name='TemplateCode', example='SMS_0000'), templateParam?: string(name='TemplateParam'), } model SendSmsResponseBody = { code?: string(name='Code', example='200'), message?: string(name='Message', example='success'), requestId?: string(name='RequestId', example='130A2C10-B9EE-4D84-88E3-5384FF039795'), resultObject?: { bizId?: string(name='BizId', example='123456^1234567'), }(name='ResultObject'), } model SendSmsResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: SendSmsResponseBody(name='body'), } async function sendSmsWithOptions(request: SendSmsRequest, runtime: Util.RuntimeOptions): SendSmsResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.mobile)) { body['Mobile'] = request.mobile; } if (!Util.isUnset(request.outerOrderNo)) { body['OuterOrderNo'] = request.outerOrderNo; } if (!Util.isUnset(request.signName)) { body['SignName'] = request.signName; } if (!Util.isUnset(request.templateCode)) { body['TemplateCode'] = request.templateCode; } if (!Util.isUnset(request.templateParam)) { body['TemplateParam'] = request.templateParam; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'SendSms', version = '2020-06-18', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function sendSms(request: SendSmsRequest): SendSmsResponse { var runtime = new Util.RuntimeOptions{}; return sendSmsWithOptions(request, runtime); } model VerifyBankElementRequest { bankCardFile?: string(name='BankCardFile'), bankCardNo?: string(name='BankCardNo'), bankCardUrl?: string(name='BankCardUrl'), idName?: string(name='IdName'), idNo?: string(name='IdNo'), mobile?: string(name='Mobile'), mode?: string(name='Mode'), outerOrderNo?: string(name='OuterOrderNo'), sceneId?: long(name='SceneId'), } model VerifyBankElementAdvanceRequest { bankCardFileObject?: readable(name='BankCardFile'), bankCardNo?: string(name='BankCardNo'), bankCardUrl?: string(name='BankCardUrl'), idName?: string(name='IdName'), idNo?: string(name='IdNo'), mobile?: string(name='Mobile'), mode?: string(name='Mode'), outerOrderNo?: string(name='OuterOrderNo'), sceneId?: long(name='SceneId'), } model VerifyBankElementResponseBody = { code?: string(name='Code'), message?: string(name='Message'), requestId?: string(name='RequestId'), resultObject?: { certifyId?: string(name='CertifyId'), materialInfo?: string(name='MaterialInfo'), passed?: string(name='Passed'), subCode?: string(name='SubCode'), }(name='ResultObject'), } model VerifyBankElementResponse = { headers: map[string]string(name='headers'), statusCode: int32(name='statusCode'), body: VerifyBankElementResponseBody(name='body'), } async function verifyBankElementWithOptions(request: VerifyBankElementRequest, runtime: Util.RuntimeOptions): VerifyBankElementResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.bankCardFile)) { body['BankCardFile'] = request.bankCardFile; } if (!Util.isUnset(request.bankCardNo)) { body['BankCardNo'] = request.bankCardNo; } if (!Util.isUnset(request.bankCardUrl)) { body['BankCardUrl'] = request.bankCardUrl; } if (!Util.isUnset(request.idName)) { body['IdName'] = request.idName; } if (!Util.isUnset(request.idNo)) { body['IdNo'] = request.idNo; } if (!Util.isUnset(request.mobile)) { body['Mobile'] = request.mobile; } if (!Util.isUnset(request.mode)) { body['Mode'] = request.mode; } if (!Util.isUnset(request.outerOrderNo)) { body['OuterOrderNo'] = request.outerOrderNo; } if (!Util.isUnset(request.sceneId)) { body['SceneId'] = request.sceneId; } var req = new OpenApi.OpenApiRequest{ body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'VerifyBankElement', version = '2020-06-18', protocol = 'HTTPS', pathname = '/', method = 'POST', authType = 'AK', style = 'RPC', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } async function verifyBankElement(request: VerifyBankElementRequest): VerifyBankElementResponse { var runtime = new Util.RuntimeOptions{}; return verifyBankElementWithOptions(request, runtime); } async function verifyBankElementAdvance(request: VerifyBankElementAdvanceRequest, runtime: Util.RuntimeOptions): VerifyBankElementResponse { // Step 0: init client var accessKeyId = @credential.getAccessKeyId(); var accessKeySecret = @credential.getAccessKeySecret(); var securityToken = @credential.getSecurityToken(); var credentialType = @credential.getType(); var openPlatformEndpoint = @openPlatformEndpoint; if(Util.isUnset(openPlatformEndpoint)) { openPlatformEndpoint ='openplatform.aliyuncs.com'; } if(Util.isUnset(credentialType)) { credentialType ='access_key'; } var authConfig = new OpenApi.Config{ accessKeyId = accessKeyId, accessKeySecret = accessKeySecret, securityToken = securityToken, type = credentialType, endpoint = openPlatformEndpoint, protocol = @protocol, regionId = @regionId, }; var authClient = new OpenPlatform(authConfig); var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{ product = 'Cloudauth', regionId = @regionId, }; var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{}; var ossConfig = new OSS.Config{ accessKeySecret = accessKeySecret, type = 'access_key', protocol = @protocol, regionId = @regionId, }; var ossClient : OSS = null; var fileObj = new FileForm.FileField{}; var ossHeader = new OSS.PostObjectRequest.header{}; var uploadRequest = new OSS.PostObjectRequest{}; var ossRuntime = new OSSUtil.RuntimeOptions{}; OpenApiUtil.convert(runtime, ossRuntime); var verifyBankElementReq = new VerifyBankElementRequest{}; OpenApiUtil.convert(request, verifyBankElementReq); if(!Util.isUnset(request.bankCardFileObject)) { authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime); ossConfig.accessKeyId = authResponse.body.accessKeyId; ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType); ossClient = new OSS(ossConfig); fileObj = new FileForm.FileField{ filename = authResponse.body.objectKey, content = request.bankCardFileObject, contentType = '', }; ossHeader = new OSS.PostObjectRequest.header{ accessKeyId = authResponse.body.accessKeyId, policy = authResponse.body.encodedPolicy, signature = authResponse.body.signature, key = authResponse.body.objectKey, file = fileObj, successActionStatus = '201', }; uploadRequest = new OSS.PostObjectRequest{ bucketName = authResponse.body.bucket, header = ossHeader, }; ossClient.postObject(uploadRequest, ossRuntime); verifyBankElementReq.bankCardFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`; } var verifyBankElementResp = verifyBankElementWithOptions(verifyBankElementReq, runtime); return verifyBankElementResp; }