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


import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.data.constants.ApiConstants;
import com.heyu.api.data.utils.StringUtils;
import com.heyu.api.baidu.BaiduBaseHandle;
import com.heyu.api.baidu.request.traffic.BWeightNoteRequest;
import com.heyu.api.baidu.response.traffic.BWeightNoteResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@CustomPath("weightNote")
public class BWeightNoteHandle extends BaiduBaseHandle<BWeightNoteRequest, BWeightNoteResp> {
    @Override
    public String getUri() {
        return "/rest/2.0/ocr/v1/weight_note";
    }

    @Override
    public String check(BWeightNoteRequest bWeightNoteRequest) {
        if (checkNotTrueFalse(bWeightNoteRequest.getProbability())) {
            return "probability必须为" + ApiConstants.trueOrFalse + ", 是否返回字段识别结果的置信度";
        }
        return checkPdf(bWeightNoteRequest);
    }

    @Override
    public String getContent(BWeightNoteRequest bWeightNoteRequest) {
        StringBuffer sb = getPdfContent(bWeightNoteRequest);
        if (StringUtils.isNotBlank(bWeightNoteRequest.getProbability())) {
            sb.append("&probability=").append(bWeightNoteRequest.getProbability());
        }

        return sb.toString();
    }
}
