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


import com.aliyun.imagerecog20190930.models.RecognizeImageColorRequest;
import com.aliyun.imagerecog20190930.models.RecognizeImageColorResponse;
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.ARecognizeImageColorRequest;
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/RecognizeImageColor
 * <p>
 * 颜色识别
 * <p>
 * RecognizelmageColor
 */
@Component
@Slf4j
@CustomPath("imageColor")
public class ARecognizeImageColorHandle extends AlibabaBaseHandle<ARecognizeImageColorRequest, RecognizeImageColorResponse> {
    @Autowired
    private com.aliyun.imagerecog20190930.Client client;

    @Override
    public String check(ARecognizeImageColorRequest aRecognizeImageColorRequest) {
        return checkUrlBase64(aRecognizeImageColorRequest);
    }


    @Override
    public RecognizeImageColorResponse run(ARecognizeImageColorRequest aRecognizeImageColorRequest, RuntimeOptions runtime) throws Exception {
        RecognizeImageColorRequest request = new RecognizeImageColorRequest();
        request.setUrl(aRecognizeImageColorRequest.getImageUrl());
        request.setColorCount(aRecognizeImageColorRequest.getColorCount());
        // 复制代码运行请自行打印 API 的返回值
        return client.recognizeImageColorWithOptions(request, runtime);
    }
}
