package com.heyu.api.tencent.handle;

import com.heyu.api.tencent.TencentBaseHandle;
import com.heyu.api.tencent.request.TIdCardVerificationRequest;
import com.tencentcloudapi.faceid.v20180301.FaceidClient;
import com.tencentcloudapi.faceid.v20180301.models.IdCardVerificationRequest;
import com.tencentcloudapi.faceid.v20180301.models.IdCardVerificationResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/***
 * https://console.cloud.tencent.com/api/explorer?Product=faceid&Version=2018-03-01&Action=IdCardVerification
 *
 *身份信息认证（二要素核验）
 *
 *
 *
 * SecretId
 *
 * AKIDCxZyA9xZx8D6lFZfcLsBHH3e1A8uTqzu
 *
 * SecretKey
 *
 * mJcjcIkz0nPnyxlMkupW1MUP7brthHjz
 *
 *
 *
 *SecretId,SecretKey
 *
 * AKIDCxZyA9xZx8D6lFZfcLsBHH3e1A8uTqzu,
 *
 * mJcjcIkz0nPnyxlMkupW1MUP7brthHjz
 */
@Component
public class TIdCardVerificationHandle extends TencentBaseHandle<TIdCardVerificationRequest, IdCardVerificationResponse> {

    @Autowired
    private FaceidClient client;

    @Override
    public String check(TIdCardVerificationRequest tIdCardVerificationRequest) {
        return checkIdCard(tIdCardVerificationRequest);
    }


    @Override
    public IdCardVerificationResponse run(TIdCardVerificationRequest tIdCardVerificationRequest) throws Exception {
        IdCardVerificationRequest idCardVerificationRequest = new IdCardVerificationRequest();
        idCardVerificationRequest.setIdCard(tIdCardVerificationRequest.getIdCard());
        idCardVerificationRequest.setName(tIdCardVerificationRequest.getName());
        // 返回的resp是一个IdCardVerificationResponse的实例，与请求对象对应
        return client.IdCardVerification(idCardVerificationRequest);
    }
}
