| @@ 80-111 (lines=32) @@ | ||
| 77 | * @param string $user |
|
| 78 | * @return Dnd |
|
| 79 | */ |
|
| 80 | public function info($user = NULL) { |
|
| 81 | ||
| 82 | // Check if the type of the variables is valid. |
|
| 83 | if (($user != NULL) && !is_string($user)) { |
|
| 84 | throw new InvalidArgumentException("The type of the user variable is not valid."); |
|
| 85 | } |
|
| 86 | ||
| 87 | // Set the arguments of the request |
|
| 88 | $arguments = array(); |
|
| 89 | ||
| 90 | if($user != NULL) { |
|
| 91 | $arguments["user"] = $user; |
|
| 92 | } |
|
| 93 | ||
| 94 | $this->setUrl("dnd.info", $arguments); |
|
| 95 | ||
| 96 | // Send the request |
|
| 97 | try { |
|
| 98 | $client = new \GuzzleHttp\Client(); |
|
| 99 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 100 | $response = json_decode( $json_response->getBody() ); |
|
| 101 | } |
|
| 102 | catch (RequestException $e) { |
|
| 103 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 104 | } |
|
| 105 | ||
| 106 | if($response->{'ok'} === FALSE) { |
|
| 107 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 108 | } |
|
| 109 | ||
| 110 | return $json_response->getBody(); |
|
| 111 | } |
|
| 112 | ||
| 113 | ||
| 114 | /** |
|
| @@ 158-189 (lines=32) @@ | ||
| 155 | * @param string $users |
|
| 156 | * @return Dnd |
|
| 157 | */ |
|
| 158 | public function teamInfo($users = NULL) { |
|
| 159 | ||
| 160 | // Check if the type of the variables is valid. |
|
| 161 | if (($user != NULL) && !is_string($user)) { |
|
| 162 | throw new InvalidArgumentException("The type of the users variable is not valid."); |
|
| 163 | } |
|
| 164 | ||
| 165 | // Set the arguments of the request |
|
| 166 | $arguments = array(); |
|
| 167 | ||
| 168 | if($user != NULL) { |
|
| 169 | $arguments["users"] = $users; |
|
| 170 | } |
|
| 171 | ||
| 172 | $this->setUrl("dnd.teamInfo", $arguments); |
|
| 173 | ||
| 174 | // Send the request |
|
| 175 | try { |
|
| 176 | $client = new \GuzzleHttp\Client(); |
|
| 177 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 178 | $response = json_decode( $json_response->getBody() ); |
|
| 179 | } |
|
| 180 | catch (RequestException $e) { |
|
| 181 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 182 | } |
|
| 183 | ||
| 184 | if($response->{'ok'} === FALSE) { |
|
| 185 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 186 | } |
|
| 187 | ||
| 188 | return $json_response->getBody(); |
|
| 189 | } |
|
| 190 | } |
|
| 191 | ||
| @@ 79-110 (lines=32) @@ | ||
| 76 | * @param string $user |
|
| 77 | * @return string |
|
| 78 | */ |
|
| 79 | public function billableInfo($user = NULL) { |
|
| 80 | ||
| 81 | // Check if the type of the variables is valid. |
|
| 82 | if (!is_string($user) && ($user != NULL)) { |
|
| 83 | throw new InvalidArgumentException("The type of the user variable is not valid."); |
|
| 84 | } |
|
| 85 | ||
| 86 | // Set the arguments of the request |
|
| 87 | $arguments = array(); |
|
| 88 | ||
| 89 | if($user != NULL) { |
|
| 90 | $arguments["user"] = $user; |
|
| 91 | } |
|
| 92 | ||
| 93 | $this->setUrl("team.billableInfo", $arguments); |
|
| 94 | ||
| 95 | // Send the request |
|
| 96 | try { |
|
| 97 | $client = new \GuzzleHttp\Client(); |
|
| 98 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 99 | $response = json_decode( $json_response->getBody() ); |
|
| 100 | } |
|
| 101 | catch (RequestException $e) { |
|
| 102 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 103 | } |
|
| 104 | ||
| 105 | if($response->{'ok'} === FALSE) { |
|
| 106 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 107 | } |
|
| 108 | ||
| 109 | return $json_response->getBody(); |
|
| 110 | } |
|
| 111 | ||
| 112 | ||
| 113 | ||
| @@ 165-196 (lines=32) @@ | ||
| 162 | * @param bool $presence |
|
| 163 | * @return string |
|
| 164 | */ |
|
| 165 | public function list($presence = NULL) { |
|
| 166 | ||
| 167 | // Check if the type of the variables is valid. |
|
| 168 | if (!is_string($presence) && ($presence != NULL)) { |
|
| 169 | throw new InvalidArgumentException("The type of the presence variable is not valid."); |
|
| 170 | } |
|
| 171 | ||
| 172 | // Set the arguments of the request |
|
| 173 | $arguments = array(); |
|
| 174 | ||
| 175 | if ($presence != NULL) { |
|
| 176 | $arguments["presence"] = $presence; |
|
| 177 | } |
|
| 178 | ||
| 179 | $this->setUrl("users.list", $arguments); |
|
| 180 | ||
| 181 | // Send the request |
|
| 182 | try { |
|
| 183 | $client = new \GuzzleHttp\Client(); |
|
| 184 | $json_response = $client->request('GET', $this->getUrl(), []); |
|
| 185 | $response = json_decode( $json_response->getBody() ); |
|
| 186 | } |
|
| 187 | catch (RequestException $e) { |
|
| 188 | throw new RuntimeException('The request to the API failed: '.$e->getMessage(), $e->getCode(), $e); |
|
| 189 | } |
|
| 190 | ||
| 191 | if($response->{'ok'} === FALSE) { |
|
| 192 | throw new RuntimeException('The request to the API failed: '.$response->{'error'}."."); |
|
| 193 | } |
|
| 194 | ||
| 195 | return $json_response->getBody(); |
|
| 196 | } |
|
| 197 | ||
| 198 | ||
| 199 | ||