package user.company;

import com.alibaba.fastjson.JSONObject;
import common.Constant;
import common.Resp;
import exception.ZXChainException;
import util.HttpUtil;
import util.ZxlSDKUtil;

public class QueryUserIdentification {
    int type;
    String cardNo;
    String name;
    String verifyCode;

    public QueryUserIdentification() {
    }

    public QueryUserIdentification(int type, String cardNo, String name, String verifyCode) {
        this.type = type;
        this.cardNo = cardNo;
        this.name = name;
        this.verifyCode = verifyCode;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getVerifyCode() {
        return verifyCode;
    }

    public void setVerifyCode(String verifyCode) {
        this.verifyCode = verifyCode;
    }

    public void query() throws Exception {
        JSONObject params = new JSONObject();
        params.put("type", this.type);
        params.put("cardNo", this.cardNo);
        params.put("name", this.name);
        params.put("verifyCode", this.verifyCode);
        Resp resp = HttpUtil.apiPostJsonX("https://open.zxchain.qq.com/api/v1/user/query", params, ZxlSDKUtil.generateApiSign());
        if (resp.getRetCode() != Constant.ZXL_OK) {
            throw new ZXChainException(resp.getRetMsg());
        }

        System.out.println(resp.getData().toString());
    }
}
