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

import com.alibaba.fastjson.JSONObject;
import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
import com.huimv.video.dhicc.test.constant.Constant;
import com.huimv.video.dhicc.test.request.BaseRequest;
import com.huimv.video.dhicc.test.request.BaseRequest02;
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;

@Data
public class ClientEventgetCarRequestHn extends BaseRequest02<Object> {



    private String urls;








    public ClientEventgetCarRequestHn() {
    }

    public ClientEventgetCarRequestHn(OauthConfigBaseInfo02 oauthConfigBaseInfo) {
        super(oauthConfigBaseInfo, Constant.HTTP_GET, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.COUNT_TIME, true);
    }

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

        System.out.println(res);
        //获取响应
        JSONObject jsonObject=JSONObject.parseObject(res);
        System.out.println(jsonObject);
        Object action = jsonObject.get("data");
        return action;
    }

    private void setBody() {
        //设置请求参数


    }


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