@@ -6,12 +6,12 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class OpenFireRestApi |
| 8 | 8 | { |
| 9 | - public $host = 'localhost'; |
|
| 10 | - public $port = '9090'; |
|
| 9 | + public $host = 'localhost'; |
|
| 10 | + public $port = '9090'; |
|
| 11 | 11 | public $plugin = '/plugins/restapi/v1'; |
| 12 | 12 | public $secret = 'SuperSecret'; |
| 13 | 13 | public $useSSL = false; |
| 14 | - protected $params = array(); |
|
| 14 | + protected $params = array(); |
|
| 15 | 15 | public $client; |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | * @return array|false Array with data or error, or False when something went fully wrong |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | - private function doRequest($type, $endpoint, $params=array()) |
|
| 36 | + private function doRequest($type, $endpoint, $params = array()) |
|
| 37 | 37 | { |
| 38 | 38 | $base = ($this->useSSL) ? "https" : "http"; |
| 39 | - $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
| 39 | + $url = $base."://".$this->host.":".$this->port.$this->plugin.$endpoint; |
|
| 40 | 40 | $headers = array( |
| 41 | 41 | 'Accept' => 'application/json', |
| 42 | 42 | 'Authorization' => $this->secret |
@@ -49,16 +49,16 @@ discard block |
||
| 49 | 49 | $result = $this->client->get($url, compact('headers')); |
| 50 | 50 | break; |
| 51 | 51 | case 'post': |
| 52 | - $headers += ['Content-Type'=>'application/json']; |
|
| 53 | - $result = $this->client->post($url, compact('headers','body')); |
|
| 52 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
| 53 | + $result = $this->client->post($url, compact('headers', 'body')); |
|
| 54 | 54 | break; |
| 55 | 55 | case 'delete': |
| 56 | - $headers += ['Content-Type'=>'application/json']; |
|
| 57 | - $result = $this->client->delete($url, compact('headers','body')); |
|
| 56 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
| 57 | + $result = $this->client->delete($url, compact('headers', 'body')); |
|
| 58 | 58 | break; |
| 59 | 59 | case 'put': |
| 60 | - $headers += ['Content-Type'=>'application/json']; |
|
| 61 | - $result = $this->client->put($url, compact('headers','body')); |
|
| 60 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
| 61 | + $result = $this->client->put($url, compact('headers', 'body')); |
|
| 62 | 62 | break; |
| 63 | 63 | default: |
| 64 | 64 | $result = null; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | public function getUsers() |
| 82 | 82 | { |
| 83 | 83 | $endpoint = '/users'; |
| 84 | - return $this->doRequest('get',$endpoint); |
|
| 84 | + return $this->doRequest('get', $endpoint); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | * @param string[]|false $groups Groups (Optional) |
| 108 | 108 | * @return json|false Json with data or error, or False when something went fully wrong |
| 109 | 109 | */ |
| 110 | - public function addUser($username, $password, $name=false, $email=false, $groups=false) |
|
| 110 | + public function addUser($username, $password, $name = false, $email = false, $groups = false) |
|
| 111 | 111 | { |
| 112 | 112 | $endpoint = '/users'; |
| 113 | - return $this->doRequest('post', $endpoint, compact('username', 'password','name','email', 'groups')); |
|
| 113 | + return $this->doRequest('post', $endpoint, compact('username', 'password', 'name', 'email', 'groups')); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | * @param string[]|false $groups Groups (Optional) |
| 137 | 137 | * @return json|false Json with data or error, or False when something went fully wrong |
| 138 | 138 | */ |
| 139 | - public function updateUser($username, $password, $name=false, $email=false, $groups=false) |
|
| 139 | + public function updateUser($username, $password, $name = false, $email = false, $groups = false) |
|
| 140 | 140 | { |
| 141 | 141 | $endpoint = '/users/'.$username; |
| 142 | - return $this->doRequest('put', $endpoint, compact('username', 'password','name','email', 'groups')); |
|
| 142 | + return $this->doRequest('put', $endpoint, compact('username', 'password', 'name', 'email', 'groups')); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | * @param int|false $subscriptionType Subscription (Optional) |
| 178 | 178 | * @return json|false Json with data or error, or False when something went fully wrong |
| 179 | 179 | */ |
| 180 | - public function addToRoster($username, $jid, $name=false, $subscriptionType=false) |
|
| 180 | + public function addToRoster($username, $jid, $name = false, $subscriptionType = false) |
|
| 181 | 181 | { |
| 182 | 182 | $endpoint = '/users/'.$username.'/roster'; |
| 183 | - return $this->doRequest('post', $endpoint, compact('jid','name','subscriptionType')); |
|
| 183 | + return $this->doRequest('post', $endpoint, compact('jid', 'name', 'subscriptionType')); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
@@ -206,10 +206,10 @@ discard block |
||
| 206 | 206 | * @param int|false $subscriptionType Subscription (Optional) |
| 207 | 207 | * @return json|false Json with data or error, or False when something went fully wrong |
| 208 | 208 | */ |
| 209 | - public function updateRoster($username, $jid, $nickname=false, $subscriptionType=false) |
|
| 209 | + public function updateRoster($username, $jid, $nickname = false, $subscriptionType = false) |
|
| 210 | 210 | { |
| 211 | 211 | $endpoint = '/users/'.$username.'/roster/'.$jid; |
| 212 | - return $this->doRequest('put', $endpoint, $jid, compact('jid','username','subscriptionType')); |
|
| 212 | + return $this->doRequest('put', $endpoint, $jid, compact('jid', 'username', 'subscriptionType')); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | public function createGroup($name, $description = false) |
| 247 | 247 | { |
| 248 | 248 | $endpoint = '/groups/'; |
| 249 | - return $this->doRequest('post', $endpoint, compact('name','description')); |
|
| 249 | + return $this->doRequest('post', $endpoint, compact('name', 'description')); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -268,10 +268,10 @@ discard block |
||
| 268 | 268 | * @param string $description Some description of the group |
| 269 | 269 | * |
| 270 | 270 | */ |
| 271 | - public function updateGroup($name, $description) |
|
| 271 | + public function updateGroup($name, $description) |
|
| 272 | 272 | { |
| 273 | 273 | $endpoint = '/groups/'.$name; |
| 274 | - return $this->doRequest('put', $endpoint, compact('name','description')); |
|
| 274 | + return $this->doRequest('put', $endpoint, compact('name', 'description')); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |