package user.common;

import common.Constant;
import common.Resp;
import exception.ZXChainException;
import util.HttpUtil;
import util.ZxlSDKUtil;
import java.util.List;

public class BindQuery {
    List<String> addressList;

    public BindQuery() {
    }

    public BindQuery(List<String> addressList) {
        this.addressList = addressList;
    }

    public List<String> getAddressList() {
        return addressList;
    }

    public void setAddressList(List<String> addressList) {
        this.addressList = addressList;
    }

    public BindQueryResp bindQuery() throws Exception {
        if (this.addressList.isEmpty()) {
            throw new IllegalArgumentException("addressList is empty!");
        }

        String queryMap = String.join("&addressList=", this.addressList);
        String url = "https://open.zxchain.qq.com/api/v1/user/identity/bind/query?addressList="+queryMap;

        //调用接口
        Resp resp = HttpUtil.apiGetJsonX(url, null, ZxlSDKUtil.generateApiSign());
        if (resp.getRetCode() != Constant.ZXL_OK) {
            throw new ZXChainException(resp.getRetMsg());
        }

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