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;

/**
 * 微服务_用户中心_5G用户查询 json_microservice_users_qryUserIsUdm
 */
public class QryUserIsUdm extends AbstractQuery {
    private static final String url = "http://192.168.70.130:8000/api/microservice/users/qryUserIsUdm/v1";
    private static final String urlTest = "http://10.124.150.230:8000/api/microservice/users/qryUserIsUdm/v1";

    public COMPConnectionContext query(String phoneNumber, String provinceCode, 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> qryUserIsUdmReq = new HashMap<>();
        req.put("QRY_USER_IS_UDM_REQ", qryUserIsUdmReq);
        qryUserIsUdmReq.put("SERIAL_NUMBER", phoneNumber);
        qryUserIsUdmReq.put("PROVINCE_CODE", provinceCode);

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