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 | 20 | 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') |
|
72 | |||
73 | /** |
||
74 | * @param string $method |
||
75 | * @return bool |
||
76 | */ |
||
77 | 5 | private function validateMethod($method) |
|
85 | |||
86 | /** |
||
87 | * @return Client |
||
88 | */ |
||
89 | 5 | public function getClient() |
|
97 | |||
98 | /** |
||
99 | * @param Client $client |
||
100 | */ |
||
101 | 4 | public function setClient(Client $client) |
|
105 | |||
106 | /** |
||
107 | * @return string |
||
108 | */ |
||
109 | 3 | public function getAppKey() |
|
113 | |||
114 | /** |
||
115 | * @param string $appKey |
||
116 | */ |
||
117 | 1 | public function setAppKey($appKey) |
|
121 | |||
122 | /** |
||
123 | * @return string |
||
124 | */ |
||
125 | 3 | public function getSecretKey() |
|
129 | |||
130 | /** |
||
131 | * @param string $secretKey |
||
132 | */ |
||
133 | 1 | public function setSecretKey($secretKey) |
|
137 | } |
||
138 |