package com.heyu.api.alibaba.handle.common.text;

import com.aliyun.ocr20191230.models.RecognizeVINCodeRequest;
import com.aliyun.ocr20191230.models.RecognizeVINCodeResponse;
import com.aliyun.teautil.models.RuntimeOptions;
import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.alibaba.AlibabaBaseHandle;
import com.heyu.api.alibaba.request.common.text.ARecognizeVINCodeRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeVINCode
 * <p>
 * VIN码识别
 */
@Component
@Slf4j
@CustomPath("VINCode")
public class ARecognizeVINCodeHandle extends AlibabaBaseHandle<ARecognizeVINCodeRequest, RecognizeVINCodeResponse> {

    @Autowired
    private com.aliyun.ocr20191230.Client client;


    @Override
    public String check(ARecognizeVINCodeRequest aRecognizeVINCodeRequest) {
        return checkUrlBase64(aRecognizeVINCodeRequest);
    }


    @Override
    public RecognizeVINCodeResponse run(ARecognizeVINCodeRequest aRecognizeVINCodeRequest, RuntimeOptions runtime) throws Exception {
        RecognizeVINCodeRequest request = new RecognizeVINCodeRequest();
        request.setImageURL(aRecognizeVINCodeRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.recognizeVINCodeWithOptions(request, runtime);

    }
}
