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


import com.alibaba.fastjson.JSON;
import com.aliyun.facebody20191230.models.GenerateHumanAnimeStyleRequest;
import com.aliyun.facebody20191230.models.GenerateHumanAnimeStyleResponse;
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.facebody.AGenerateHumanAnimeStyleRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * https://next.api.aliyun.com/api/facebody/2019-12-30/GenerateHumanAnimeStyle
 * 人物动漫化
 */
@Component
@Slf4j
@CustomPath("generateHumanAnimeStyle")
public class AGenerateHumanAnimeStyleHandle extends AlibabaBaseHandle<AGenerateHumanAnimeStyleRequest, GenerateHumanAnimeStyleResponse> {


    public final static List<String> suportAlgoType = Arrays.asList("anime",
            "3d",
            "handdrawn",
            "sketch",
            "artstyle",
            "claborate",
            "hongkong",
            "comic");


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


    @Override
    public String check(AGenerateHumanAnimeStyleRequest aGenerateHumanAnimeStyleRequest) {
        if (!suportAlgoType.contains(aGenerateHumanAnimeStyleRequest.getAlgoType())) {
            return "algoType 只能传:" + JSON.toJSONString(aGenerateHumanAnimeStyleRequest.getAlgoType());
        }
        return checkUrlBase64(aGenerateHumanAnimeStyleRequest);
    }


    @Override
    public GenerateHumanAnimeStyleResponse run(AGenerateHumanAnimeStyleRequest aGenerateHumanAnimeStyleRequest, RuntimeOptions runtime) throws Exception {
        GenerateHumanAnimeStyleRequest generateHumanAnimeStyleRequest = new GenerateHumanAnimeStyleRequest();
        generateHumanAnimeStyleRequest.setImageURL(aGenerateHumanAnimeStyleRequest.getImageUrl());
// 复制代码运行请自行打印 API 的返回值
        return client.generateHumanAnimeStyleWithOptions(generateHumanAnimeStyleRequest, runtime);
    }
}
