public function getUser($userId) { $users = $this->getUsers(); if (!isset($users[$userId])) { throw new \InvalidArgumentException('This user does not exist in Slack API'); } return $this->userEntityBuilder->getUser($this->userBuilder->getUser($users[$userId])); }
public function getAll() { $payload = new UsersListPayload(); $response = $this->apiClient->send($payload); if ($response->isOk()) { return array_map(function (User $user) { return $this->userBuilder->getUser($user); }, $response->getUsers()); } else { throw new SlackApiException($response->getError()); } }