@@ -27,8 +27,8 @@ |
||
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 |
@@ -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,15 +20,15 @@ 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 | - public function geti() |
|
29 | - { |
|
30 | - return $this->host. ' '. $this->secret; |
|
31 | - } |
|
28 | + public function geti() |
|
29 | + { |
|
30 | + return $this->host. ' '. $this->secret; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | 34 | |
@@ -40,29 +40,29 @@ discard block |
||
40 | 40 | * @param array $params Parameters |
41 | 41 | * @return array|false Array with data or error, or False when something went fully wrong |
42 | 42 | */ |
43 | - protected function doRequest($type, $endpoint, $params=[]) |
|
43 | + protected function doRequest($type, $endpoint, $params=[]) |
|
44 | 44 | { |
45 | - $base = ($this->useSSL) ? "https" : "http"; |
|
46 | - $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
45 | + $base = ($this->useSSL) ? "https" : "http"; |
|
46 | + $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
47 | 47 | |
48 | - if ($this->useBasicAuth) |
|
48 | + if ($this->useBasicAuth) |
|
49 | 49 | $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd); |
50 | 50 | else |
51 | 51 | $auth = $this->secret; |
52 | 52 | |
53 | - $headers = array( |
|
54 | - 'Accept' => 'application/json', |
|
55 | - 'Authorization' => $auth |
|
56 | - ); |
|
53 | + $headers = array( |
|
54 | + 'Accept' => 'application/json', |
|
55 | + 'Authorization' => $auth |
|
56 | + ); |
|
57 | 57 | |
58 | 58 | $body = json_encode($params); |
59 | 59 | // $headers += ['Content-Type'=>'application/json']; |
60 | 60 | |
61 | 61 | |
62 | 62 | try { |
63 | - $result = $this->client->request($type, $url, compact('headers','body')); |
|
63 | + $result = $this->client->request($type, $url, compact('headers','body')); |
|
64 | 64 | } catch (Exception $e) { |
65 | - $result = $e->message; |
|
65 | + $result = $e->message; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 |