package ev;

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

public class EvQuery {
    String evId;
    String hash;
    String txId;

    public EvQuery() {
    }

    public EvQuery(String evId, String hash, String txId) {
        this.evId = evId;
        this.hash = hash;
        this.txId = txId;
    }

    public EvQueryResp query() throws Exception {
        Resp resp = HttpUtil.apiGetJsonX(Config.baseUrl + "/api/v1/ev/query", Tools.getJson(this), ZxlSDKUtil.generateApiSign());
        if (resp.getRetCode() != Constant.ZXL_OK) {
            throw new ZXChainException(resp.getRetMsg());
        }

        return resp.getData(EvQueryResp.class);
    }

    @Override
    public String toString() {
        return "EvQueryReq{" +
                "evId='" + evId + '\'' +
                ", hash='" + hash + '\'' +
                ", txId='" + txId + '\'' +
                '}';
    }

    public String getEvId() {
        return evId;
    }

    public void setEvId(String evId) {
        this.evId = evId;
    }

    public String getHash() {
        return hash;
    }

    public void setHash(String hash) {
        this.hash = hash;
    }

    public String getTxId() {
        return txId;
    }

    public void setTxId(String txId) {
        this.txId = txId;
    }
}
