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_microservice_users_pkgvalue
 */
public class PkgValue extends AbstractQuery {
    private static final String url = "http://192.168.70.130:8000/api/microservice/users/pkgvalue/v1";
    private static final String urlTest = "http://10.124.150.230:8000/api/microservice/users/pkgvalue/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> pkgValueReq = new HashMap<>();
        req.put("PKGVALUE_REQ", pkgValueReq);
        Map<String, Object> req2 = new HashMap<>();
        pkgValueReq.put("REQ", req2);
        req2.put("SERIAL_NUMBER", phoneNumber);
        req2.put("PROVINCE_CODE", provinceCode);
        req2.put("EPARCHY_CODE", eparchyCode);
        COMPConnectionContext context = compConnection.excute(Const.HttpMethodType.POST, realUrl, req, false);
        return context;
    }
}
