updateRobot method

Future<NIMResult<V2NIMUserAIBot>> updateRobot(
  1. V2NIMUpdateUserAIBotParams params
)

Updates a robot and synchronizes its latest data to the local cache.

Implementation

Future<NIMResult<V2NIMUserAIBot>> updateRobot(
  V2NIMUpdateUserAIBotParams params,
) async {
  final accountId = _accountProvider();
  final accid = params.accid;
  if (accid == null || accid.isEmpty || !_isCurrentAccount(accountId)) {
    return NIMResult.failure(message: 'invalid accid');
  }
  final result = await NimCore.instance.aiService.updateUserAIBot(params);
  if (!result.isSuccess) {
    return NIMResult.failure(
      code: result.code,
      message: result.errorDetails,
    );
  }
  return _fetchAndCacheRobot(
    accountId: accountId!,
    accid: accid,
    name: params.name,
    icon: params.icon,
  );
}