You have to be logged in and have relevant permissions.
$listing = \ATDev\RocketChat\Groups\Group::listing();
if (!$listing) {
// Log the error
$error = \ATDev\RocketChat\Groups\Group::getError();
}
$listAll = \ATDev\RocketChat\Groups\Group::listAll();
if (!$listAll) {
$error = \ATDev\RocketChat\Groups\Group::getError();
}
$group = new \ATDev\RocketChat\Groups\Group();
$group->setName("[GROUP-NAME-NO-SPACES]");
$group->setReadOnlyValue(true);
$result = $group->create();
if (!$result) {
// Log the error
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->info();
if (!$result) {
// Log the error
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->delete();
if (!$result) {
// Log the error
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->open();
if (!$result) {
// Log the error
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->close();
if (!$result) {
// Log the error
$error = $group->getError();
}
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->invite($user);
if (!$result) {
// Log the error
$error = $group->getError();
}
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->kick($user);
if (!$result) {
// Log the error
$error = $group->getError();
}
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->addOwner($user);
if (!$result) {
// Log the error
$error = $group->getError();
}
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->removeOwner($user);
if (!$result) {
// Log the error
$error = $group->getError();
}
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->removeOwner($user);
if (!$result) {
// Log the error
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->messages();
if (!$result) {
// Log the error
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$result = $group->addLeader($user);
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$result = $group->removeLeader($user);
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$result = $group->addModerator($user);
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$user = new \ATDev\RocketChat\Users\User("[USER ID]");
$result = $group->removeModerator($user);
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->moderators();
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->leave();
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->members();
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->counters();
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->archive();
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->unarchive();
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->rename("[NEW-GROUP-NAME]");
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->setDescription("[GROUP DESCRIPTION]");
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->setAnnouncement("[GROUP ANNOUNCEMENT]");
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->setCustomFields(["CUSTOM-FIELD" => "VALUE"]);
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->setReadOnly(true);
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->setTopic("[NEW GROUP TOPIC]");
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->setType("c");
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$roles = $group->roles();
if (!$roles) {
$error = $group->getError();
} else {
$roles->first()->getRoles();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->history([
"latest" => "2016-09-30T13:42:25.304Z",
"oldest" => "2016-05-30T13:42:25.304Z",
"inclusive" => true,
"unreads" => true
]);
if (!$result) {
$error = $group->getError();
}
$group = new \ATDev\RocketChat\Groups\Group("[GROUP ID]");
$result = $group->files(10, 20);
if (!$result) {
$error = $group->getError();
}