You are here

public function ApiClient::channelsHistory in Rocket.Chat 8.2

Same name and namespace in other branches
  1. 8 modules/rocket_chat_api/src/RocketChat/ApiClient.php \Drupal\rocket_chat_api\RocketChat\ApiClient::channelsHistory()

Retrieve the message history information.

Parameters

string $roomId: The roomId to look up.

bool $unreads: Include the amount of unreads.

bool $inclusive: Are the limits inclusive or exclusive.

int $count: How many to retrieve max.

string $latest: Timestring for the jongest message to retrieve.

string $oldest: Timestring for the max age of a message.

Return value

array Result Array.

File

modules/rocket_chat_api/src/RocketChat/ApiClient.php, line 532

Class

ApiClient
Class ApiClient.

Namespace

Drupal\rocket_chat_api\RocketChat

Code

public function channelsHistory($roomId, $unreads = NULL, $inclusive = NULL, $count = NULL, $latest = NULL, $oldest = NULL) {

  // Time Example = "1970-01-01T01:00:00.00Z".
  $req = [];
  $req['query'] = [];
  $req['query']['roomId'] = $roomId;
  if (!empty($latest)) {
    $req['query']['latest'] = $latest;
  }
  if (!empty($oldest)) {
    $req['query']['oldest'] = $oldest;
  }
  if (isset($inclusive)) {
    $req['query']['inclusive'] = $inclusive;
  }
  if (!empty($count)) {
    $req['query']['count'] = $count;
  }
  if (isset($unreads)) {
    $req['query']['unreads'] = $unreads;
  }
  return $this
    ->getFromRocketChat('channels.history', $req);
}