getBanUsersFromChannel static method
Implementation
static Future<bool> getBanUsersFromChannel(TPChannel tpChannel,
TPUser? lastUser,
Function(List<TPUser>, bool) successCallback,
{
Function(int? errorCode, String? errorMessage)? errorCallback
}) async
{
if (!_isInitialized(errorCallback: errorCallback)) { return false; }
if (!_checkAuthInfo(errorCallback: errorCallback)) { return false; }
try {
String url = "/channels/${tpChannel.getChannelId()}/members/banned";
// lastUserId
if ((lastUser == null ? 0 : lastUser.getUserId().length) > 0) {
url += "?lastUserId=${lastUser!.getUserId()}";
}
Map<String, dynamic> response = await HttpUtil.get(url);
// TPMember List
List<TPUser> tpUsers = List.from([]);
for (Map<String, dynamic> element in response["users"]) {
tpUsers.add(TPUser(element));
}
// Succeeded
successCallback(tpUsers, response["hasNext"]);
return true;
} 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 false;
}