package com.nokia.domainb.capability;

import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

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

/*
 * 短信用户投诉分析查询接口
 * json_chinaUnicom_hb18_complaintManagement_usercomplaintQuerys
 */
public class UsercomplaintQuerys extends AbstractQuery {
    private static final String url = "http://133.96.94.184:47996/ete/v1/rest/openApi/usercomplaintQuerys";
    private static final String urlTest = "http://10.124.150.230:8000/api/chinaUnicom/hb18/complaintManagement/usercomplaintQuerys/v1";

    public String query(String mobile, String destAddr, String complaintType, String isMobile,
            String flowNo, String beginTime, String endTime, String token, boolean test) {
        String realUrl = test ? urlTest : url;
        // REQ
        Map<String, Object> req = new HashMap<>();
        req.put("mobile", mobile);
        req.put("destAddr", destAddr);
        req.put("complaintType", complaintType);
        req.put("isMobile", isMobile);
        req.put("flowNo", flowNo);
        req.put("beginTime", beginTime);
        req.put("endTime", endTime);
        req.put("token", token);
        RestTemplate restTemplate = new RestTemplate();
        ResponseEntity<String> response = restTemplate.postForEntity(realUrl, req, String.class);
        return response.getBody();
    }
}
