package com.huimv.video.dhicc.test.request;

import com.alibaba.fastjson.JSON;
import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo03;
import com.huimv.video.dhicc.test.constant.Constant;
import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
import com.huimv.video.dhicc.test.utils.UrlUtil;
import lombok.Data;

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

@Data
public class ClientCarCaptureRequestCn extends BaseRequest03<Object> {



//    private List<String> a;
    private String pageNum;

    private String pageSize;






    public ClientCarCaptureRequestCn() {
    }

    public ClientCarCaptureRequestCn(OauthConfigBaseInfo03 oauthConfigBaseInfo) {
        super(oauthConfigBaseInfo, Constant.HTTP_GET, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.CAR_CAPTURE_RECORD, true);
    }

    @Override
    public Object doAction() {
        //重置url信息，替换版本号
        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
        //设置请求参数
        this.setUrl(this.getUrl().replace("{pageNum}",pageNum));
        this.setUrl(this.getUrl().replace("{pageSize}",pageSize));
        //发送请求
        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doGet03(this) : HttpsURLConnectionUtil.doGet03(this);

        System.out.println(res);
        //获取响应

        return res;
    }

    private void setBody() {
        //设置请求参数
        /*List<String> map = new ArrayList<>();
        map = this.a;*/
        Map<String, String> map = new HashMap<>();
        map.put("pageNum", this.pageNum);
        map.put("pageSize", this.pageSize);
        this.setBody(JSON.toJSONString(map));

    }


    public boolean isEnableHttpTest() {
        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
    }
}
