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_credits_isblackname todo: 可以先不做，需要先调用用户资料三户返回接口
 */
public class IsBlackName extends AbstractQuery {
    private static final String url = "http://192.168.70.130:8000/api/microservice/credits/isblackname/v1";
    private static final String urlTest = "http://10.124.150.230:8000/api/microservice/credits/isblackname/v1";

    public COMPConnectionContext query(String phoneNumber, 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> isBlackNameReq = new HashMap<>();
        req.put("ISBLACKNAME_REQ", isBlackNameReq);
        isBlackNameReq.put("PROVINCE_CODE", "18");
        isBlackNameReq.put("PSPT_ID", "131182198504092057");
        isBlackNameReq.put("PSPT_TYPE_CODE", "1");

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