1 | <?php |
||
8 | class HttpClient |
||
9 | { |
||
10 | const API_URL = 'https://api.smslabs.net.pl/apiSms'; |
||
11 | |||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $appKey = null; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $secretKey = null; |
||
21 | |||
22 | /** |
||
23 | * @var Client |
||
24 | */ |
||
25 | private $client = null; |
||
26 | |||
27 | /** |
||
28 | * HttpClient constructor. |
||
29 | * @param string $appKey |
||
30 | * @param string $secretKey |
||
31 | */ |
||
32 | 16 | public function __construct($appKey, $secretKey) |
|
37 | |||
38 | /** |
||
39 | * @param string $url |
||
40 | * @param array $data |
||
41 | * @param string $method |
||
42 | * @return array |
||
43 | * @throws InvalidResponseException |
||
44 | */ |
||
45 | 4 | public function sendRequest($url, $data = null, $method = 'GET') |
|
73 | 4 | ||
74 | /** |
||
75 | 4 | * @param string $method |
|
76 | 1 | * @return bool |
|
77 | */ |
||
78 | private function validateMethod($method) |
||
86 | |||
87 | 4 | /** |
|
88 | 1 | * @return Client |
|
89 | 1 | */ |
|
90 | public function getClient() |
||
98 | |||
99 | 3 | /** |
|
100 | 3 | * @param Client $client |
|
101 | */ |
||
102 | public function setClient(Client $client) |
||
106 | |||
107 | 3 | /** |
|
108 | * @return string |
||
109 | */ |
||
110 | public function getAppKey() |
||
114 | |||
115 | 1 | /** |
|
116 | 1 | * @param string $appKey |
|
117 | */ |
||
118 | public function setAppKey($appKey) |
||
122 | |||
123 | 3 | /** |
|
124 | * @return string |
||
125 | */ |
||
126 | public function getSecretKey() |
||
130 | |||
131 | 1 | /** |
|
132 | 1 | * @param string $secretKey |
|
133 | */ |
||
134 | public function setSecretKey($secretKey) |
||
138 | } |
||
139 |