package com.heyu.api.alibaba.handle.imagerecog;


import com.aliyun.imagerecog20190930.models.DetectImageElementsRequest;
import com.aliyun.imagerecog20190930.models.DetectImageElementsResponse;
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.imagerecog.ADetectImageElementsRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/imagerecog/2019-09-30/DetectImageElements?tab=DEMO&lang=JAVA
 * <p>
 * <p>
 * 元素识别
 * <p>
 * DetectlmageElements
 */
@Component
@Slf4j
@CustomPath("detectImageElements")
public class ADetectImageElementsHandle extends AlibabaBaseHandle<ADetectImageElementsRequest, DetectImageElementsResponse> {


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


    @Override
    public String check(ADetectImageElementsRequest aDetectImageElementsRequest) {
        return checkUrlBase64(aDetectImageElementsRequest);
    }



    @Override
    public DetectImageElementsResponse run(ADetectImageElementsRequest aDetectImageElementsRequest, RuntimeOptions runtime) throws Exception {
        DetectImageElementsRequest request = new DetectImageElementsRequest();
        request.setUrl(aDetectImageElementsRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.detectImageElementsWithOptions(request, runtime);
    }
}
