package com.nokia.domainb.capability;

import cn.chinaunicom.open.common.Const;
import cn.chinaunicom.open.nlgxptconnection.COMPConnection;
import cn.chinaunicom.open.nlgxptconnection.COMPConnectionContext;
import cn.chinaunicom.open.nlgxptconnection.impl.COMPJsonConnection;

import java.util.HashMap;
import java.util.Map;

/**
 * 查询用户产品信息 json_chinaUnicom_microservice_users_qryuserprodmsg
 */
public class QryUserProdMsg extends AbstractQuery {
    private static final String url = "http://192.168.70.130:8000/api/chinaUnicom/microservice/users/qryuserprodmsg/v1";
    private static final String urlTest = "http://10.124.150.230:8000/api/chinaUnicom/microservice/users/qryuserprodmsg/v1";

    public COMPConnectionContext query(String phoneNumber, String provinceCode, String eparchyCode, boolean test) {
        String realAppSecret = test ? appSecretTest : appSecret;
        String realUrl = test ? urlTest : url;
        COMPConnection compConnection = new COMPJsonConnection(appId, realAppSecret);

        // REQ
        Map<String, Object> req = new HashMap<>();
        Map<String, Object> qryUserProdMsgReq = new HashMap<>();
        req.put("QRYUSERPRODMSG_REQ", qryUserProdMsgReq);
        qryUserProdMsgReq.put("SERIAL_NUMBER", phoneNumber);
        qryUserProdMsgReq.put("PROVINCE_CODE", provinceCode);
        qryUserProdMsgReq.put("EPARCHY_CODE", eparchyCode);

        qryUserProdMsgReq.put("NET_TYPE_CODE", "50");

        COMPConnectionContext context = compConnection.excute(Const.HttpMethodType.POST, realUrl, req, false);
        return context;
    }
}
