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

import com.aliyun.ocr20191230.models.RecognizeTicketInvoiceRequest;
import com.aliyun.ocr20191230.models.RecognizeTicketInvoiceResponse;
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.ARecognizeTicketInvoiceRequest;
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/RecognizeTicketInvoice
 *
 * <p>
 * 增值税发票卷票识别
 */
@Component
@Slf4j
@CustomPath("ticketInvoice")
public class ARecognizeTicketInvoiceHandle extends AlibabaBaseHandle<ARecognizeTicketInvoiceRequest, RecognizeTicketInvoiceResponse> {

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


    @Override
    public String check(ARecognizeTicketInvoiceRequest aRecognizeTicketInvoiceRequest) {
        return checkUrlBase64(aRecognizeTicketInvoiceRequest);
    }


    @Override
    public RecognizeTicketInvoiceResponse run(ARecognizeTicketInvoiceRequest aRecognizeTicketInvoiceRequest, RuntimeOptions runtime) throws Exception {
        RecognizeTicketInvoiceRequest recognizeTicketInvoiceRequest = new RecognizeTicketInvoiceRequest();
        recognizeTicketInvoiceRequest.setImageURL(aRecognizeTicketInvoiceRequest.getImageUrl());

        //    // 复制代码运行请自行打印 API 的返回值
        return client.recognizeTicketInvoiceWithOptions(recognizeTicketInvoiceRequest, runtime);
    }
}
