package com.heyu.api.tencent.handle;


import com.heyu.api.data.annotation.QPS;
import com.heyu.api.data.utils.StringUtils;
import com.heyu.api.tencent.TencentBaseHandle;
import com.heyu.api.tencent.request.TMobileStatusRequest;
import com.tencentcloudapi.faceid.v20180301.FaceidClient;
import com.tencentcloudapi.faceid.v20180301.models.MobileStatusRequest;
import com.tencentcloudapi.faceid.v20180301.models.MobileStatusResponse;
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=MobileStatus
 *手机号状态查询
 */
@Component
@QPS(50)
public class TMobileStatusHandle extends TencentBaseHandle<TMobileStatusRequest, MobileStatusResponse> {

    @Autowired
    private FaceidClient client;


    @Override
    public String check(TMobileStatusRequest tMobileStatusRequest) {
        if (StringUtils.isNotEmpty(tMobileStatusRequest.getMobile())) {
            return "手机号不能为空";
        }
        return "";
    }

    @Override
    public MobileStatusResponse run(TMobileStatusRequest ap) throws Exception {
        MobileStatusRequest mobileStatusRequest = new MobileStatusRequest();
        mobileStatusRequest.setMobile(ap.getMobile());
        return client.MobileStatus(mobileStatusRequest);
    }
}
