package com.nokia.domainb.capability;

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

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;

/*
 * 垃圾短信黑名单查询接口
 * json_chinaUnicom_hb18_complaintManagement_smsBlacklistQuery
 */
public class SmsBlacklistQuery extends AbstractQuery {
    // TODO 正式上线后才能获取到正式环境url
    private static final String url = "";
    private static final String urlTest = "http://10.124.150.230:8000/api/chinaUnicom/hb18/complaintManagement/smsBlacklistQuery/v1";

    public COMPConnectionContext query(String phone, String fromSystem, 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> smsBlackListQueryReq = new HashMap<>();
        req.put("SMS_BLACKLIST_QUERY_REQ", smsBlackListQueryReq);

        smsBlackListQueryReq.put("phone", phone);
        smsBlackListQueryReq.put("fromSystem", fromSystem);

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