public function Channel::changeChannelName in Rocket.Chat 8.2
File
- modules/rocket_chat_api/ src/ RocketChat/ Element/ Channel.php, line 616 
Class
Namespace
Drupal\rocket_chat_api\RocketChat\ElementCode
public function changeChannelName(ApiClient $apiClient, string $newName) {
  $channelProxy = $this
    ->getChannelProxy($apiClient);
  if (strcmp($this
    ->getSafeChannelName(), self::toSafeChannelName($newName) !== 0)) {
    $methodBase = $this
      ->getChannelTypeName();
    $rename = [];
    $rename['json'] = [];
    $rename['json']['roomId'] = $this->Channel['_id'];
    $rename['json']['name'] = self::toSafeChannelName($newName);
    $ret = $apiClient
      ->postToRocketChat($methodBase . ".rename", $rename);
    //TODO implement better Check.
    $this->Channel = $ret['body'][rtrim($methodBase, "s")];
    $state = Drupal::service('state');
    $ChannelList = new Channels(new Drupal8State($state), $apiClient);
    $ChannelList
      ->refreshCache(TRUE);
  }
}