refreshRobotToken method
Refreshes a robot token and synchronizes the refreshed robot to cache.
Implementation
Future<NIMResult<V2NIMUserAIBot>> refreshRobotToken(String accid) async {
final accountId = _accountProvider();
if (accid.isEmpty || !_isCurrentAccount(accountId)) {
return NIMResult.failure(message: 'invalid accid');
}
final refreshResult = await NimCore.instance.aiService
.refreshUserAIBotToken(V2NIMRefreshUserAIBotTokenParams(accid: accid));
if (!refreshResult.isSuccess) {
return NIMResult.failure(
code: refreshResult.code,
message: refreshResult.errorDetails,
);
}
return _fetchAndCacheRobot(
accountId: accountId!,
accid: accid,
token: refreshResult.data?.token,
);
}