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

import com.aliyun.ocr20191230.models.RecognizeBankCardRequest;
import com.aliyun.ocr20191230.models.RecognizeBankCardResponse;
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.ARecognizeBankCardRequest;
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/RecognizeBankCard
 * 银行卡识别
 */
@Component
@Slf4j
@CustomPath("bankCard")
public class ARecognizeBankCardHandle extends AlibabaBaseHandle<ARecognizeBankCardRequest, RecognizeBankCardResponse> {

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

    @Override
    public String check(ARecognizeBankCardRequest recognizeBankCardRequest) {
        return checkUrlBase64(recognizeBankCardRequest);
    }

    @Override
    public RecognizeBankCardResponse run(ARecognizeBankCardRequest aRecognizeBankCardRequest, RuntimeOptions runtime) throws Exception {

        RecognizeBankCardRequest recognizeBankCardRequest = new RecognizeBankCardRequest();
        recognizeBankCardRequest.setImageURL(aRecognizeBankCardRequest.getImageUrl());

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

}

