| @@ 28-71 (lines=44) @@ | ||
| 25 | * @param bool $mpim_aware |
|
| 26 | * @return Reminders |
|
| 27 | */ |
|
| 28 | public function start($simple_latest = NULL, $no_unreads = NULL, $mpim_aware = NULL) { |
|
| 29 | ||
| 30 | // Check if the type of the variables is valid. |
|
| 31 | if (($simple_latest != NULL) && !is_bool($simple_latest)) { |
|
| 32 | throw new InvalidArgumentException("The type of the simple_latest variable is not valid."); |
|
| 33 | } |
|
| 34 | if (($no_unreads != NULL) && !is_bool($no_unreads)) { |
|
| 35 | throw new InvalidArgumentException("The type of the no_unreads variable is not valid."); |
|
| 36 | } |
|
| 37 | if (($mpim_aware != NULL) && !is_bool($mpim_aware)) { |
|
| 38 | throw new InvalidArgumentException("The type of the mpim_aware variable is not valid."); |
|
| 39 | } |
|
| 40 | ||
| 41 | // Set the arguments of the request |
|
| 42 | $arguments = array(); |
|
| 43 | ||
| 44 | if ($simple_latest != NULL) { |
|
| 45 | $arguments["simple_latest"] = $simple_latest; |
|
| 46 | } |
|
| 47 | if ($no_unreads != NULL) { |
|
| 48 | $arguments["no_unreads"] = $no_unreads; |
|
| 49 | } |
|
| 50 | if ($mpim_aware != NULL) { |
|
| 51 | $arguments["mpim_aware"] = $mpim_aware; |
|
| 52 | } |
|
| 53 | ||
| 54 | $this->setUrl("rtm.start", $arguments); |
|
| 55 | ||
| 56 | // Send the request |
|
| 57 | try { |
|
| 58 | $client = new \GuzzleHttp\Client(); |
|
| 59 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 60 | $response = json_decode( $json_response->getBody() ); |
|
| 61 | } |
|
| 62 | catch (RequestException $e) { |
|
| 63 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 64 | } |
|
| 65 | ||
| 66 | if($response->{'ok'} === FALSE) { |
|
| 67 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 68 | } |
|
| 69 | ||
| 70 | return $json_response->getBody(); |
|
| 71 | } |
|
| 72 | } |
|
| 73 | ||
| @@ 194-237 (lines=44) @@ | ||
| 191 | * @param bool $include_users |
|
| 192 | * @return string |
|
| 193 | */ |
|
| 194 | public function list($include_disabled = NULL, $include_count = NULL, $include_users = NULL) { |
|
| 195 | ||
| 196 | // Check if the type of the variables is valid. |
|
| 197 | if (!is_bool($include_disabled) && ($include_disabled != NULL)) { |
|
| 198 | throw new InvalidArgumentException("The type of the include_disabled variable is not valid."); |
|
| 199 | } |
|
| 200 | if (!is_bool($include_count) && ($include_count != NULL)) { |
|
| 201 | throw new InvalidArgumentException("The type of the include_count variable is not valid."); |
|
| 202 | } |
|
| 203 | if (!is_bool($include_users) && ($include_users != NULL)) { |
|
| 204 | throw new InvalidArgumentException("The type of the include_users variable is not valid."); |
|
| 205 | } |
|
| 206 | ||
| 207 | // Set the arguments of the request |
|
| 208 | $arguments = array(); |
|
| 209 | ||
| 210 | if ($include_disabled != NULL) { |
|
| 211 | $arguments["include_disabled"] = $include_disabled; |
|
| 212 | } |
|
| 213 | if ($include_count != NULL) { |
|
| 214 | $arguments["include_count"] = $include_count; |
|
| 215 | } |
|
| 216 | if ($include_users != NULL) { |
|
| 217 | $arguments["include_users"] = $include_users; |
|
| 218 | } |
|
| 219 | ||
| 220 | $this->setUrl("usergroups.list", $arguments); |
|
| 221 | ||
| 222 | // Send the request |
|
| 223 | try { |
|
| 224 | $client = new \GuzzleHttp\Client(); |
|
| 225 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 226 | $response = json_decode( $json_response->getBody() ); |
|
| 227 | } |
|
| 228 | catch (RequestException $e) { |
|
| 229 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 230 | } |
|
| 231 | ||
| 232 | if($response->{'ok'} === FALSE) { |
|
| 233 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 234 | } |
|
| 235 | ||
| 236 | return $json_response->getBody(); |
|
| 237 | } |
|
| 238 | ||
| 239 | ||
| 240 | ||