package com.mosty.base.utils;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;

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

public class CameraPreviewUtil {

	public static String getCameraPreviewURL(String url, JSONObject jsonBody) {
		/**
		 * STEP1：设置平台参数，根据实际情况,设置host appkey appsecret 三个参数.
		 */
//		ArtemisConfig.host = "80.149.27.26:443"; // 平台的ip端口
//		ArtemisConfig.appKey = "21247884";  // 密钥appkey
//		ArtemisConfig.appSecret = "7H5ISjWWHuhHfZ03SQEG";// 密钥appSecret
		//海康环境
//		ArtemisConfig.host = "51.140.38.2:443";
//		ArtemisConfig.appKey = "24245087";
//		ArtemisConfig.appSecret = "KSGeqKJiIcVw0Gg9dKwC";

		ArtemisConfig.host = "80.187.1.30:443";// 代理API网关nginx服务器ip端口
		ArtemisConfig.appKey = "29494762";// 秘钥appkey
		ArtemisConfig.appSecret = "8VxmuHUSxhJQw55LkPea";// 秘钥appSecret
		/**
		 * STEP2：设置OpenAPI接口的上下文
		 */
		final String ARTEMIS_PATH = "/artemis";
		/**
		 * STEP3：设置接口的URI地址
		 */
		final String previewURLsApi = ARTEMIS_PATH + url;
		Map<String, String> path = new HashMap<String, String>(2) {
			{
				put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
			}
		};
		/**
		 * STEP4：设置参数提交方式
		 */
		String contentType = "application/json";
		String body = jsonBody.toJSONString();
		/**
		 * STEP6：调用接口
		 */
		String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
		return result;
	}

}
