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


import com.aliyun.facebody20191230.models.MonitorExaminationRequest;
import com.aliyun.facebody20191230.models.MonitorExaminationResponse;
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.AMonitorExaminationRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/facebody/2019-12-30/MonitorExamination?tab=DOC&lang=JAVA
 * 线上监考
 * <p>
 * MonitorExamination
 */
@Component
@Slf4j
@CustomPath("monitorExamination")
public class AMonitorExaminationHandle extends AlibabaBaseHandle<AMonitorExaminationRequest, MonitorExaminationResponse> {

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


    @Override
    public String check(AMonitorExaminationRequest aMonitorExaminationRequest) {
        if (aMonitorExaminationRequest.getType() == null) {
            return "请填写type的值，取值枚举0,1";
        }
        return checkUrlBase64(aMonitorExaminationRequest);
    }


    @Override
    public MonitorExaminationResponse run(AMonitorExaminationRequest aMonitorExaminationRequest, RuntimeOptions runtime) throws Exception {
        MonitorExaminationRequest request = new MonitorExaminationRequest();
        request.setType(aMonitorExaminationRequest.getType());
        request.setImageURL(aMonitorExaminationRequest.getImageUrl());
        // 复制代码运行请自行打印 API 的返回值
        return client.monitorExaminationWithOptions(request, runtime);
    }
}
