updateTPChannel static method
Implementation
static Future<TPChannel?> updateTPChannel(
TPChannelUpdateParams params,
{ Function(int? errorCode, String? errorMessage)? errorCallback }) async
{
if (!_isInitialized(errorCallback: errorCallback)) { return null; }
if (!_checkAuthInfo(errorCallback: errorCallback)) { return null; }
Map<String, dynamic> body = Map.from({});
if(params.hideMessagesBeforeJoin != null) { body["hideMessagesBeforeJoin"] = params.hideMessagesBeforeJoin; }
if(params.maxMemberCount != null) { body["maxMemberCount"] = params.maxMemberCount; }
if(params.channelName != null) { body["name"] = params.channelName; }
if(params.invitationCode != null) { body["invitationCode"] = params.invitationCode; }
if(params.category != null) { body["category"] = params.category; }
if(params.subCategory != null) { body["subcategory"] = params.subCategory; }
if(params.imageUrl != null) { body["imageUrl"] = params.imageUrl; }
if(params.metaData?.isNotEmpty ?? false) { body["data"] = params.metaData; }
try {
String url = "/channels/${params.channel.getChannelId()}";
Map<String, dynamic> response = await HttpUtil.put(url, body);
Map<String, dynamic> channel = response["channel"];
return TPChannel(channel);
} on TPException catch(e) {
Logger.log("$e");
if(errorCallback != null) { errorCallback(e.getCode(), e.getMessage()); }
} catch(e){
Logger.log("$e");
if(errorCallback != null) { errorCallback(-1, e.toString()); }
}
return null;
}