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


import com.aliyun.imageenhan20190930.models.GenerateDynamicImageRequest;
import com.aliyun.imageenhan20190930.models.GenerateDynamicImageResponse;
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.imageenhan.AGenerateDynamicImageRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/imageenhan/2019-09-30/GenerateDynamicImage?tab=DOC
 * <p>
 * 图像微动
 * <p>
 * GenerateDynamiclmage
 */
@Component
@Slf4j
@CustomPath("generateDynamicImage")
public class AGenerateDynamicImageHandle extends AlibabaBaseHandle<AGenerateDynamicImageRequest, GenerateDynamicImageResponse> {

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


    @Override
    public String check(AGenerateDynamicImageRequest aGenerateDynamicImageRequest) {
        return checkUrlBase64(aGenerateDynamicImageRequest);
    }


    @Override
    public GenerateDynamicImageResponse run(AGenerateDynamicImageRequest aGenerateDynamicImageRequest, RuntimeOptions runtime) throws Exception {
        GenerateDynamicImageRequest generateDynamicImageRequest = new GenerateDynamicImageRequest();
        generateDynamicImageRequest.setOperation(aGenerateDynamicImageRequest.getOperation());
        generateDynamicImageRequest.setUrl(aGenerateDynamicImageRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.generateDynamicImageWithOptions(generateDynamicImageRequest, runtime);
    }
}
