package com.heyu.api.tencent.handle;


import com.heyu.api.data.utils.StringUtils;
import com.heyu.api.tencent.TencentBaseHandle;
import com.heyu.api.tencent.request.TMobileNetworkTimeVerificationRequest;
import com.tencentcloudapi.faceid.v20180301.FaceidClient;
import com.tencentcloudapi.faceid.v20180301.models.MobileNetworkTimeVerificationRequest;
import com.tencentcloudapi.faceid.v20180301.models.MobileNetworkTimeVerificationResponse;
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=MobileNetworkTimeVerification
 * 手机号在网时长核验
 */
@Component
public class TMobileNetworkTimeVerificationHandle extends TencentBaseHandle<TMobileNetworkTimeVerificationRequest, MobileNetworkTimeVerificationResponse> {


    @Autowired
    private FaceidClient client;


    @Override
    public String check(TMobileNetworkTimeVerificationRequest tMobileNetworkTimeVerificationRequest) {

        if(StringUtils.isBlank(tMobileNetworkTimeVerificationRequest.getMobile())){
            return "手机号不能为空";
        }




        return null;
    }

    @Override
    public MobileNetworkTimeVerificationResponse run(TMobileNetworkTimeVerificationRequest ap) throws Exception {

        MobileNetworkTimeVerificationRequest    req = new MobileNetworkTimeVerificationRequest();
        req.setMobile(ap.getMobile());


        // 返回的resp是一个MobileNetworkTimeVerificationResponse的实例，与请求对象对应
        MobileNetworkTimeVerificationResponse resp = client.MobileNetworkTimeVerification(req);

        return resp;
    }
}
