| @@ 28-68 (lines=41) @@ | ||
| 25 | * @param string $as_user |
|
| 26 | * @return Chat |
|
| 27 | */ |
|
| 28 | public function delete($ts, $channel, $as_user = NULL) { |
|
| 29 | ||
| 30 | // Check if the type of the variables is valid. |
|
| 31 | if (!is_float($ts)) { |
|
| 32 | throw new InvalidArgumentException("The type of the ts variable is not valid."); |
|
| 33 | } |
|
| 34 | if (!is_string($channel)) { |
|
| 35 | throw new InvalidArgumentException("The type of the channel variable is not valid."); |
|
| 36 | } |
|
| 37 | if (($as_user != NULL) && !is_bool($as_user)) { |
|
| 38 | throw new InvalidArgumentException("The type of the as_user variable is not valid."); |
|
| 39 | } |
|
| 40 | ||
| 41 | // Set the arguments of the request |
|
| 42 | $arguments = array( |
|
| 43 | "ts" => (string)$ts, |
|
| 44 | "channel" => $channel |
|
| 45 | ); |
|
| 46 | ||
| 47 | if($as_user != NULL) { |
|
| 48 | $arguments["as_user"] = $as_user; |
|
| 49 | } |
|
| 50 | ||
| 51 | $this->setUrl("chat.delete", $arguments); |
|
| 52 | ||
| 53 | // Send the request |
|
| 54 | try { |
|
| 55 | $client = new \GuzzleHttp\Client(); |
|
| 56 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 57 | $response = json_decode( $json_response->getBody() ); |
|
| 58 | } |
|
| 59 | catch (RequestException $e) { |
|
| 60 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 61 | } |
|
| 62 | ||
| 63 | if($response->{'ok'} === FALSE) { |
|
| 64 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 65 | } |
|
| 66 | ||
| 67 | return $json_response->getBody(); |
|
| 68 | } |
|
| 69 | ||
| 70 | ||
| 71 | ||
| @@ 28-68 (lines=41) @@ | ||
| 25 | * @param string $channel |
|
| 26 | * @return FilesComments |
|
| 27 | */ |
|
| 28 | public function add($file, $comment, $channel = NULL) { |
|
| 29 | ||
| 30 | // Check if the type of the variables is valid. |
|
| 31 | if (!is_string($file)) { |
|
| 32 | throw new InvalidArgumentException("The type of the file variable is not valid."); |
|
| 33 | } |
|
| 34 | if (!is_string($comment)) { |
|
| 35 | throw new InvalidArgumentException("The type of the comment variable is not valid."); |
|
| 36 | } |
|
| 37 | if (($channel != NULL) && !is_string($channel)) { |
|
| 38 | throw new InvalidArgumentException("The type of the channel variable is not valid."); |
|
| 39 | } |
|
| 40 | ||
| 41 | // Set the arguments of the request |
|
| 42 | $arguments = array( |
|
| 43 | "file" => $file, |
|
| 44 | "comment" => $comment |
|
| 45 | ); |
|
| 46 | ||
| 47 | if($channel != NULL) { |
|
| 48 | $arguments["channel"] = $channel; |
|
| 49 | } |
|
| 50 | ||
| 51 | $this->setUrl("files.comments.add", $arguments); |
|
| 52 | ||
| 53 | // Send the request |
|
| 54 | try { |
|
| 55 | $client = new \GuzzleHttp\Client(); |
|
| 56 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 57 | $response = json_decode( $json_response->getBody() ); |
|
| 58 | } |
|
| 59 | catch (RequestException $e) { |
|
| 60 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 61 | } |
|
| 62 | ||
| 63 | if($response->{'ok'} === FALSE) { |
|
| 64 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 65 | } |
|
| 66 | ||
| 67 | return $json_response->getBody(); |
|
| 68 | } |
|
| 69 | ||
| 70 | ||
| 71 | /** |
|
| @@ 28-68 (lines=41) @@ | ||
| 25 | * @param string $user |
|
| 26 | * @return Reminders |
|
| 27 | */ |
|
| 28 | public function add($text, $time, $user = NULL) { |
|
| 29 | ||
| 30 | // Check if the type of the variables is valid. |
|
| 31 | if (!is_string($text)) { |
|
| 32 | throw new InvalidArgumentException("The type of the text variable is not valid."); |
|
| 33 | } |
|
| 34 | if (!is_integer($time)) { |
|
| 35 | throw new InvalidArgumentException("The type of the time variable is not valid."); |
|
| 36 | } |
|
| 37 | if (($user != NULL) && !is_string($user)) { |
|
| 38 | throw new InvalidArgumentException("The type of the user variable is not valid."); |
|
| 39 | } |
|
| 40 | ||
| 41 | // Set the arguments of the request |
|
| 42 | $arguments = array( |
|
| 43 | "text" => $text, |
|
| 44 | "time" => (string)$time |
|
| 45 | ); |
|
| 46 | ||
| 47 | if ($user != NULL) { |
|
| 48 | $arguments["user"] = $user; |
|
| 49 | } |
|
| 50 | ||
| 51 | $this->setUrl("reminders.add", $arguments); |
|
| 52 | ||
| 53 | // Send the request |
|
| 54 | try { |
|
| 55 | $client = new \GuzzleHttp\Client(); |
|
| 56 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 57 | $response = json_decode( $json_response->getBody() ); |
|
| 58 | } |
|
| 59 | catch (RequestException $e) { |
|
| 60 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 61 | } |
|
| 62 | ||
| 63 | if($response->{'ok'} === FALSE) { |
|
| 64 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 65 | } |
|
| 66 | ||
| 67 | return $json_response->getBody(); |
|
| 68 | } |
|
| 69 | ||
| 70 | ||
| 71 | ||
| @@ 28-68 (lines=41) @@ | ||
| 25 | * @param string $before |
|
| 26 | * @return string |
|
| 27 | */ |
|
| 28 | public function accessLogs($count = 100, $page = 1, $before = NULL) { |
|
| 29 | ||
| 30 | // Check if the type of the variables is valid. |
|
| 31 | if (!is_int($count)) { |
|
| 32 | throw new InvalidArgumentException("The type of the count variable is not valid."); |
|
| 33 | } |
|
| 34 | if (!is_int($page)) { |
|
| 35 | throw new InvalidArgumentException("The type of the page variable is not valid."); |
|
| 36 | } |
|
| 37 | if (!is_int($before) && ($before != NULL)) { |
|
| 38 | throw new InvalidArgumentException("The type of the before variable is not valid."); |
|
| 39 | } |
|
| 40 | ||
| 41 | // Set the arguments of the request |
|
| 42 | $arguments = array( |
|
| 43 | "count" => $count, |
|
| 44 | "page" => $page |
|
| 45 | ); |
|
| 46 | ||
| 47 | if ($before != NULL) { |
|
| 48 | $arguments["before"] = $before; |
|
| 49 | } |
|
| 50 | ||
| 51 | $this->setUrl("team.accessLogs", $arguments); |
|
| 52 | ||
| 53 | // Send the request |
|
| 54 | try { |
|
| 55 | $client = new \GuzzleHttp\Client(); |
|
| 56 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 57 | $response = json_decode( $json_response->getBody() ); |
|
| 58 | } |
|
| 59 | catch (RequestException $e) { |
|
| 60 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 61 | } |
|
| 62 | ||
| 63 | if($response->{'ok'} === FALSE) { |
|
| 64 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 65 | } |
|
| 66 | ||
| 67 | return $json_response->getBody(); |
|
| 68 | } |
|
| 69 | ||
| 70 | ||
| 71 | ||