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 | 27 | 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 | 5 | public function sendRequest($url, $data = null, $method = 'GET') |
|
64 | |||
65 | /** |
||
66 | * @param string $json |
||
67 | * @return array |
||
68 | * @throws InvalidResponseException |
||
69 | */ |
||
70 | 3 | private function parseJsonData($json) |
|
84 | |||
85 | /** |
||
86 | * @param string $method |
||
87 | * @return bool |
||
88 | */ |
||
89 | 5 | private function validateHttpMethod($method) |
|
93 | |||
94 | /** |
||
95 | * @return Client |
||
96 | */ |
||
97 | 5 | public function getClient() |
|
105 | |||
106 | /** |
||
107 | * @param Client $client |
||
108 | */ |
||
109 | 4 | public function setClient(Client $client) |
|
113 | |||
114 | /** |
||
115 | * @return string |
||
116 | */ |
||
117 | 3 | public function getAppKey() |
|
121 | |||
122 | /** |
||
123 | * @param string $appKey |
||
124 | * @return HttpClient $this |
||
125 | */ |
||
126 | 1 | public function setAppKey($appKey) |
|
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | 3 | public function getSecretKey() |
|
140 | |||
141 | /** |
||
142 | * @param string $secretKey |
||
143 | * @return HttpClient $this |
||
144 | */ |
||
145 | 1 | public function setSecretKey($secretKey) |
|
151 | } |
||
152 |