|
1 | 1 | <?php |
2 | 2 |
|
3 | | - |
4 | 3 | namespace Pitwch\RestAPIWrapperProffix; |
5 | 4 |
|
6 | 5 | use Pitwch\RestAPIWrapperProffix\HttpClient\HttpClient; |
7 | 6 |
|
8 | | - |
9 | 7 | /** |
10 | 8 | * Class Client |
11 | 9 | * |
12 | 10 | * @package Pitwch\RestAPIWrapperProffix |
13 | 11 | */ |
14 | 12 | class Client |
15 | 13 | { |
| 14 | + protected $httpClient; |
16 | 15 |
|
17 | | - const VERSION = '1.3'; |
18 | | - |
19 | | - |
20 | | - /** |
21 | | - * @var HttpClient |
22 | | - */ |
23 | | - protected $http; |
24 | | - |
25 | | - /** |
26 | | - * Client constructor. |
27 | | - * |
28 | | - * @param string $url The Proffix API URL |
29 | | - * @param string $apiDatabase The Proffix Database |
30 | | - * @param string $apiUser The Proffix User |
31 | | - * @param string $apiPassword The Proffix Password |
32 | | - * @param array $apiModules The required Proffix Modules |
33 | | - * @param array $options Additional options |
34 | | - * |
35 | | - * @throws HttpClient\HttpClientException |
36 | | - */ |
37 | 16 | public function __construct($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options = []) |
38 | 17 | { |
39 | | - $this->http = new HttpClient($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options); |
| 18 | + $this->httpClient = new HttpClient($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options); |
40 | 19 | } |
41 | 20 |
|
42 | | - |
43 | | - /** |
44 | | - * @param string $endpoint |
45 | | - * @param array $data |
46 | | - * |
47 | | - * @return mixed |
48 | | - * |
49 | | - * @throws HttpClient\HttpClientException |
50 | | - */ |
51 | | - public function post($endpoint, $data) |
| 21 | + public function getHttpClient() |
52 | 22 | { |
53 | | - return $this->http->request($endpoint, 'POST', $data); |
| 23 | + return $this->httpClient; |
54 | 24 | } |
55 | 25 |
|
56 | | - /** |
57 | | - * @param string $endpoint |
58 | | - * @param array $data |
59 | | - * |
60 | | - * @return mixed |
61 | | - * |
62 | | - * @throws HttpClient\HttpClientException |
63 | | - */ |
64 | | - public function put($endpoint, $data) |
| 26 | + public function get($endpoint, $parameters = []) |
65 | 27 | { |
66 | | - return $this->http->request($endpoint, 'PUT', $data); |
| 28 | + return $this->httpClient->request($endpoint, 'GET', [], $parameters); |
67 | 29 | } |
68 | 30 |
|
69 | | - /** |
70 | | - * @param string $endpoint |
71 | | - * @param array $parameters |
72 | | - * |
73 | | - * @return mixed |
74 | | - * |
75 | | - * @throws HttpClient\HttpClientException |
76 | | - */ |
77 | | - public function get($endpoint, $parameters = []) |
| 31 | + public function post($endpoint, $data = []) |
78 | 32 | { |
| 33 | + return $this->httpClient->request($endpoint, 'POST', $data); |
| 34 | + } |
79 | 35 |
|
80 | | - return $this->http->request($endpoint, 'GET', [], $parameters); |
| 36 | + public function put($endpoint, $data = []) |
| 37 | + { |
| 38 | + return $this->httpClient->request($endpoint, 'PUT', $data); |
81 | 39 | } |
82 | 40 |
|
83 | | - /** |
84 | | - * @param string $endpoint |
85 | | - * @param array $parameters |
86 | | - * |
87 | | - * @return mixed |
88 | | - * |
89 | | - * @throws HttpClient\HttpClientException |
90 | | - */ |
91 | 41 | public function delete($endpoint, $parameters = []) |
92 | 42 | { |
93 | | - return $this->http->request($endpoint, 'DELETE', [], $parameters); |
| 43 | + return $this->httpClient->request($endpoint, 'DELETE', [], $parameters); |
94 | 44 | } |
95 | 45 |
|
96 | | - /** |
97 | | - * @param string $px_api_key |
98 | | - * |
99 | | - * @return mixed |
100 | | - * |
101 | | - * @throws HttpClient\HttpClientException |
102 | | - */ |
103 | 46 | public function info($px_api_key = '') |
104 | 47 | { |
105 | | - return $this->http->request('PRO/Info', 'GET', [], ['key' => $px_api_key], false); |
| 48 | + return $this->httpClient->request('PRO/Info', 'GET', [], ['key' => $px_api_key], false); |
106 | 49 | } |
107 | 50 |
|
108 | | - /** |
109 | | - * @param string $px_api_key |
110 | | - * |
111 | | - * @return mixed |
112 | | - * |
113 | | - * @throws HttpClient\HttpClientException |
114 | | - */ |
115 | 51 | public function database($px_api_key = '') |
116 | 52 | { |
117 | | - return $this->http->request('PRO/Datenbank', 'GET', [], ['key' => $px_api_key], false); |
| 53 | + return $this->httpClient->request('PRO/Datenbank', 'GET', [], ['key' => $px_api_key], false); |
118 | 54 | } |
119 | | - |
120 | | - |
121 | 55 | } |
| 56 | + |
0 commit comments