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.BBusinessLicenseRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;


/**
 * https://console.bce.baidu.com/support/?_=1668425998119&timestamp=1742560340214#/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%2Fbusiness_license&method=post
 *
 *
 *
 * 营业执照识别
 */
@Component
@Slf4j
@CustomPath("businessLicense")
public class BBusinessLicenseHandle extends BaiduBaseHandle<BBusinessLicenseRequest, Map> {

    @Override
    public String getUri() {
        return "/rest/2.0/ocr/v1/business_license";
    }

    @Override
    public String check(BBusinessLicenseRequest businessLicenseRequest) {
        return checkImageUri(businessLicenseRequest);
    }


    @Override
    public String getContent(BBusinessLicenseRequest businessLicenseRequest) {
        StringBuffer sb = getImageContent(businessLicenseRequest);

        if (StringUtils.isNotBlank(businessLicenseRequest.getAccuracy())) {
            sb.append("&accuracy=").append(businessLicenseRequest.getAccuracy());
        }

        if (StringUtils.isNotBlank(businessLicenseRequest.getRiskWarn())) {
            sb.append("&risk_warn=").append(businessLicenseRequest.getRiskWarn());
        }
        return sb.toString();
    }
}
