private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
* 创建角色
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testAddChannelAccount() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/channel/account/create";
String channelId = "2824409";
String role = "Assistant";
String actor = "助教sadboy";
String nickName = "昵称sadboy";
String avatar = "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png";
String passwd = "test123456";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
List<Map<String, String>> purviewList = new ArrayList<>();
Map<String, String> purviewMap1 = new HashMap<>();
purviewMap1.put("code", "chatListEnabled");
purviewMap1.put("enabled", "N");
purviewList.add(purviewMap1);
Map<String, String> purviewMap2 = new HashMap<>();
purviewMap2.put("code", "monitorEnabled");
purviewMap2.put("enabled", "Y");
purviewList.add(purviewMap2);
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("role", role);
jsonMap.put("actor", actor);
jsonMap.put("nickName", nickName);
jsonMap.put("avatar", avatar);
jsonMap.put("passwd", passwd);
jsonMap.put("purviewList", purviewList);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
log.info("测试创建角色成功:{}", response);
//do somethings
}