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') |
|
74 | |||
75 | /** |
||
76 | * @param string $method |
||
77 | * @return bool |
||
78 | */ |
||
79 | 5 | private function validateHttpMethod($method) |
|
83 | |||
84 | /** |
||
85 | * @return Client |
||
86 | */ |
||
87 | 5 | public function getClient() |
|
95 | |||
96 | /** |
||
97 | * @param Client $client |
||
98 | */ |
||
99 | 4 | public function setClient(Client $client) |
|
103 | |||
104 | /** |
||
105 | * @return string |
||
106 | */ |
||
107 | 3 | public function getAppKey() |
|
111 | |||
112 | /** |
||
113 | * @param string $appKey |
||
114 | * @return HttpClient $this |
||
115 | */ |
||
116 | 1 | public function setAppKey($appKey) |
|
122 | |||
123 | /** |
||
124 | * @return string |
||
125 | */ |
||
126 | 3 | public function getSecretKey() |
|
130 | |||
131 | /** |
||
132 | * @param string $secretKey |
||
133 | * @return HttpClient $this |
||
134 | */ |
||
135 | 1 | public function setSecretKey($secretKey) |
|
141 | } |
||
142 |