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


import com.aliyun.imagerecog20190930.models.RecognizeImageStyleRequest;
import com.aliyun.imagerecog20190930.models.RecognizeImageStyleResponse;
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.ARecognizeImageStyleRequest;
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("imageStyle")
public class ARecognizeImageStyleHandle extends AlibabaBaseHandle<ARecognizeImageStyleRequest, RecognizeImageStyleResponse> {

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

    @Override
    public String check(ARecognizeImageStyleRequest aRecognizeImageStyleRequest) {
        return checkUrlBase64(aRecognizeImageStyleRequest);
    }


    @Override
    public RecognizeImageStyleResponse run(ARecognizeImageStyleRequest aRecognizeImageStyleRequest, RuntimeOptions runtime) throws Exception {
        RecognizeImageStyleRequest recognizeImageStyleRequest = new RecognizeImageStyleRequest();
        recognizeImageStyleRequest.setUrl(aRecognizeImageStyleRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.recognizeImageStyleWithOptions(recognizeImageStyleRequest, runtime);
    }
}
