package com.heyu.api.baidu.handle.certificate;



import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.data.utils.StringUtils;
import com.heyu.api.baidu.BaiduBaseHandle;
import com.heyu.api.baidu.request.certificate.BFourFactorsVerificationRequest;
import com.heyu.api.baidu.response.certificate.BFourFactorsVerificationResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740312979599#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E5%8D%A1%E8%AF%81OCR&api=rest%2F2.0%2Focr%2Fv1%2Ftwo_factors_verification&method=post
 * <p>
 * <p>
 * 企业二要素核验
 */
@Component
@Slf4j
@CustomPath("fourFactorsVerification")
public class BFourFactorsVerificationHandle extends BaiduBaseHandle<BFourFactorsVerificationRequest, BFourFactorsVerificationResp> {
    @Override
    public String getUri() {
        return "/rest/2.0/ocr/v1/four_factors_verification";
    }

    @Override
    public String check(BFourFactorsVerificationRequest aTwoFactorsVerificationRequest) {
        if (StringUtils.isBlank(aTwoFactorsVerificationRequest.getName())) {
            return "name 法人姓名不能为空";
        }


        if (StringUtils.isBlank(aTwoFactorsVerificationRequest.getIdcard())) {
            return "idcard 法人身份证号码为空";
        }

        if (StringUtils.isBlank(aTwoFactorsVerificationRequest.getCompany())) {
            return "company 企业名称不能为空";
        }
        if (StringUtils.isBlank(aTwoFactorsVerificationRequest.getRegnum())) {
            return "regnum 社会统一信用代码不能为空";
        }
        return null;
    }

    @Override
    public String getContent(BFourFactorsVerificationRequest aTwoFactorsVerificationRequest) {
        StringBuffer sb = new StringBuffer();
        sb.append("&name=").append(aTwoFactorsVerificationRequest.getName());
        sb.append("&idcard=").append(aTwoFactorsVerificationRequest.getIdcard());
        sb.append("&company=").append(aTwoFactorsVerificationRequest.getCompany());
        sb.append("&regnum=").append(aTwoFactorsVerificationRequest.getRegnum());
        return sb.toString();
    }
}
