@@ -25,7 +25,9 @@ |
||
| 25 | 25 | { |
| 26 | 26 | $query = ''; |
| 27 | 27 | |
| 28 | - if(isset($opts['search'])) $query .= '?search='.$opts['search']; |
|
| 28 | + if(isset($opts['search'])) { |
|
| 29 | + $query .= '?search='.$opts['search']; |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | 32 | $endpoint = '/users'.$query; |
| 31 | 33 | return $this->doRequest('GET', $endpoint); |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | if(isset($opts['search'])) $query .= '?search='.$opts['search']; |
| 29 | 29 | |
| 30 | - $endpoint = '/users'.$query; |
|
| 31 | - return $this->doRequest('GET', $endpoint); |
|
| 30 | + $endpoint = '/users'.$query; |
|
| 31 | + return $this->doRequest('GET', $endpoint); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
@@ -413,11 +413,11 @@ discard block |
||
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | |
| 416 | - /** |
|
| 417 | - * Get all groups |
|
| 418 | - * |
|
| 419 | - * @return json|false Json with data or error, or False when something went fully wrong |
|
| 420 | - */ |
|
| 416 | + /** |
|
| 417 | + * Get all groups |
|
| 418 | + * |
|
| 419 | + * @return json|false Json with data or error, or False when something went fully wrong |
|
| 420 | + */ |
|
| 421 | 421 | public function getGroups() |
| 422 | 422 | { |
| 423 | 423 | $endpoint = '/groups'; |
@@ -45,10 +45,11 @@ |
||
| 45 | 45 | $base = ($this->useSSL) ? "https" : "http"; |
| 46 | 46 | $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
| 47 | 47 | |
| 48 | - if ($this->useBasicAuth) |
|
| 49 | - $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd); |
|
| 50 | - else |
|
| 51 | - $auth = $this->secret; |
|
| 48 | + if ($this->useBasicAuth) { |
|
| 49 | + $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd); |
|
| 50 | + } else { |
|
| 51 | + $auth = $this->secret; |
|
| 52 | + } |
|
| 52 | 53 | |
| 53 | 54 | $headers = array( |
| 54 | 55 | 'Accept' => 'application/json', |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | class RestClient |
| 10 | 10 | { |
| 11 | - public $host = 'localhost'; |
|
| 11 | + public $host = 'localhost'; |
|
| 12 | 12 | public $port = '9090'; |
| 13 | 13 | public $plugin = '/plugins/restapi/v1'; |
| 14 | 14 | public $secret = 'SuperSecret'; |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | public $basicUser = 'admin'; |
| 21 | 21 | public $basicPwd = '1234'; |
| 22 | 22 | |
| 23 | - function __construct() |
|
| 24 | - { |
|
| 25 | - $this->client = new Client(); |
|
| 26 | - } |
|
| 23 | + function __construct() |
|
| 24 | + { |
|
| 25 | + $this->client = new Client(); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Make the request and analyze the result |
@@ -33,28 +33,28 @@ discard block |
||
| 33 | 33 | * @param array $params Parameters |
| 34 | 34 | * @return array|false Array with data or error, or False when something went fully wrong |
| 35 | 35 | */ |
| 36 | - protected function doRequest($type, $endpoint, $params=[]) |
|
| 36 | + protected function doRequest($type, $endpoint, $params=[]) |
|
| 37 | 37 | { |
| 38 | - $base = ($this->useSSL) ? "https" : "http"; |
|
| 39 | - $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
| 38 | + $base = ($this->useSSL) ? "https" : "http"; |
|
| 39 | + $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
| 40 | 40 | |
| 41 | - if ($this->useBasicAuth) |
|
| 41 | + if ($this->useBasicAuth) |
|
| 42 | 42 | $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd); |
| 43 | 43 | else |
| 44 | 44 | $auth = $this->secret; |
| 45 | 45 | |
| 46 | - $headers = array( |
|
| 47 | - 'Accept' => 'application/json', |
|
| 48 | - 'Authorization' => $auth, |
|
| 46 | + $headers = array( |
|
| 47 | + 'Accept' => 'application/json', |
|
| 48 | + 'Authorization' => $auth, |
|
| 49 | 49 | 'Content-Type'=>'application/json' |
| 50 | - ); |
|
| 50 | + ); |
|
| 51 | 51 | |
| 52 | 52 | $body = json_encode($params); |
| 53 | 53 | |
| 54 | 54 | try { |
| 55 | - $result = $this->client->request($type, $url, compact('headers','body')); |
|
| 55 | + $result = $this->client->request($type, $url, compact('headers','body')); |
|
| 56 | 56 | } catch (\Exception $e) { |
| 57 | - return ['status'=>false, 'data'=>['message'=>$e->getMessage()]]; |
|
| 57 | + return ['status'=>false, 'data'=>['message'=>$e->getMessage()]]; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |