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.BTwoFactorsVerificationRequest;
import com.heyu.api.baidu.response.certificate.BTwoFactorsVerificationResp;
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("birthCertificate")
public class BTwoFactorsVerificationHandle extends BaiduBaseHandle<BTwoFactorsVerificationRequest, BTwoFactorsVerificationResp> {
    @Override
    public String getUri() {
        return "/rest/2.0/ocr/v1/two_factors_verification";
    }

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

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