| @@ 68-77 (lines=10) @@ | ||
| 65 | * |
|
| 66 | * @return FileInfo|ResponseInterface |
|
| 67 | */ |
|
| 68 | public function getFileInfo(string $fileId) |
|
| 69 | { |
|
| 70 | if (empty($fileId)) { |
|
| 71 | throw new InvalidArgumentException('FileID can not be empty'); |
|
| 72 | } |
|
| 73 | ||
| 74 | $response = $this->httpGet(sprintf('/files/%s/info', $fileId)); |
|
| 75 | ||
| 76 | return $this->handleResponse($response, FileInfo::class); |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * Gets a file that has been uploaded previously. |
|
| @@ 98-107 (lines=10) @@ | ||
| 95 | * |
|
| 96 | * @return Status|ResponseInterface |
|
| 97 | */ |
|
| 98 | public function pinPost($postId) |
|
| 99 | { |
|
| 100 | if (empty($postId)) { |
|
| 101 | throw new InvalidArgumentException('PostId can not be empty'); |
|
| 102 | } |
|
| 103 | ||
| 104 | $response = $this->httpPost(sprintf('/posts/%s/pin', $postId)); |
|
| 105 | ||
| 106 | return $this->handleResponse($response, Status::class); |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * Unpin a post to a channel it is in based from the provided post id string. |
|
| @@ 118-127 (lines=10) @@ | ||
| 115 | * |
|
| 116 | * @return Status|ResponseInterface |
|
| 117 | */ |
|
| 118 | public function unpinPost($postId) |
|
| 119 | { |
|
| 120 | if (empty($postId)) { |
|
| 121 | throw new InvalidArgumentException('PostId can not be empty'); |
|
| 122 | } |
|
| 123 | ||
| 124 | $response = $this->httpPost(sprintf('/posts/%s/unpin', $postId)); |
|
| 125 | ||
| 126 | return $this->handleResponse($response, Status::class); |
|
| 127 | } |
|
| 128 | ||
| 129 | /** |
|
| 130 | * Soft deletes a post, by marking the post as deleted in the database. Soft deleted posts will not be returned in post queries. |
|
| @@ 25-34 (lines=10) @@ | ||
| 22 | * |
|
| 23 | * @return Channel|ResponseInterface |
|
| 24 | */ |
|
| 25 | public function getChannelById(string $channelId) |
|
| 26 | { |
|
| 27 | if (empty($channelId)) { |
|
| 28 | throw new InvalidArgumentException('Id can not be empty'); |
|
| 29 | } |
|
| 30 | ||
| 31 | $response = $this->httpGet(sprintf('/channels/%s', $channelId)); |
|
| 32 | ||
| 33 | return $this->handleResponse($response, Channel::class); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Returns an channel by its ID. |
|
| @@ 135-144 (lines=10) @@ | ||
| 132 | * |
|
| 133 | * @return Channel|ResponseInterface |
|
| 134 | */ |
|
| 135 | public function restoreChannel($channelId) |
|
| 136 | { |
|
| 137 | if (empty($channelId)) { |
|
| 138 | throw new InvalidArgumentException('ChannelId can not be empty'); |
|
| 139 | } |
|
| 140 | ||
| 141 | $response = $this->httpPost(sprintf('/channels/%s/restore', $channelId)); |
|
| 142 | ||
| 143 | return $this->handleResponse($response, Channel::class); |
|
| 144 | } |
|
| 145 | ||
| 146 | /** |
|
| 147 | * Patch a channel. |
|
| @@ 72-81 (lines=10) @@ | ||
| 69 | * |
|
| 70 | * @return User|ResponseInterface |
|
| 71 | */ |
|
| 72 | public function getUserTeams(string $userId) |
|
| 73 | { |
|
| 74 | if (empty($userId)) { |
|
| 75 | throw new InvalidArgumentException('UserId can not be empty'); |
|
| 76 | } |
|
| 77 | ||
| 78 | $response = $this->httpGet(sprintf('/users/%s/teams', $userId)); |
|
| 79 | ||
| 80 | return $this->handleResponse($response, Teams::class); |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Returns a collection of users matching the given IDs. |
|
| @@ 90-99 (lines=10) @@ | ||
| 87 | * |
|
| 88 | * @return Users|ResponseInterface |
|
| 89 | */ |
|
| 90 | public function getUsersByIds(array $userIds) |
|
| 91 | { |
|
| 92 | if (empty($userIds)) { |
|
| 93 | throw new InvalidArgumentException('UserIDs can not be empty'); |
|
| 94 | } |
|
| 95 | ||
| 96 | $response = $this->httpPost('/users/ids', $userIds); |
|
| 97 | ||
| 98 | return $this->handleResponse($response, Users::class); |
|
| 99 | } |
|
| 100 | ||
| 101 | /** |
|
| 102 | * Returns a collection of users. |
|
| @@ 142-151 (lines=10) @@ | ||
| 139 | * |
|
| 140 | * @return Users|ResponseInterface |
|
| 141 | */ |
|
| 142 | public function getUsersByUsernames(array $userNames) |
|
| 143 | { |
|
| 144 | if (empty($userNames)) { |
|
| 145 | throw new InvalidArgumentException('Usernames can not be empty'); |
|
| 146 | } |
|
| 147 | ||
| 148 | $response = $this->httpPost('/users/usernames', $userNames); |
|
| 149 | ||
| 150 | return $this->handleResponse($response, Users::class); |
|
| 151 | } |
|
| 152 | ||
| 153 | /** |
|
| 154 | * Update user active or inactive status. |
|
| @@ 161-172 (lines=12) @@ | ||
| 158 | * |
|
| 159 | * @return Status|ResponseInterface |
|
| 160 | */ |
|
| 161 | public function setUserActive(string $userId, bool $activeStatus) |
|
| 162 | { |
|
| 163 | if (empty($userId)) { |
|
| 164 | throw new InvalidArgumentException('User ID can not be empty'); |
|
| 165 | } |
|
| 166 | ||
| 167 | $response = $this->httpPut(sprintf('/users/%s/active', $userId), [ |
|
| 168 | 'active' => $activeStatus, |
|
| 169 | ]); |
|
| 170 | ||
| 171 | return $this->handleResponse($response, Status::class); |
|
| 172 | } |
|
| 173 | ||
| 174 | /** |
|
| 175 | * Deactivates the user by archiving its user object. |
|
| @@ 204-215 (lines=12) @@ | ||
| 201 | * |
|
| 202 | * @return Status|ResponseInterface |
|
| 203 | */ |
|
| 204 | public function updateUserRoles(string $userId, string $roles) |
|
| 205 | { |
|
| 206 | if (empty($userId)) { |
|
| 207 | throw new InvalidArgumentException('User ID can not be empty'); |
|
| 208 | } |
|
| 209 | ||
| 210 | $response = $this->httpPut(sprintf('/users/%s/roles', $userId), [ |
|
| 211 | 'roles' => $roles, |
|
| 212 | ]); |
|
| 213 | ||
| 214 | return $this->handleResponse($response, Status::class); |
|
| 215 | } |
|
| 216 | ||
| 217 | /** |
|
| 218 | * Create a user. Required parameters: 'username', 'email' and 'password'. |
|