package nft.publish_nft;

import config.Config;
import common.Resp;
import exception.ZXChainException;
import util.HttpUtil;
import util.Tools;
import util.ZxlSDKUtil;

public class QueryPublishResult {
    String platformPubKey;
    String taskId;

    public QueryPublishResult() {
    }

    public QueryPublishResult(String taskId) {
        this.taskId = taskId;
    }

    public String getPlatformPubKey() {
        return platformPubKey;
    }

    public void setPlatformPubKey(String platformPubKey) {
        this.platformPubKey = platformPubKey;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public PublishResult queryPublishResult() throws Exception {
        // todo 参数校验
        this.setPlatformPubKey(Config.platformPubKey);
        Resp resp = HttpUtil.apiGetJsonX(Config.baseUrl + "/api/v1/nft/publish/result", Tools.getJson(this), ZxlSDKUtil.generateApiSign());
        if (resp.getRetCode() != 0) {
            throw new ZXChainException(resp.getRetMsg());
        }

        return resp.getData(PublishResult.class);
    }
}
