1 | <?php |
||
12 | class Request |
||
13 | { |
||
14 | /** |
||
15 | * Base url from api |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | private $baseUrl = ''; |
||
20 | |||
21 | const CURL_TYPE_AUTH = "AUTH"; |
||
22 | const CURL_TYPE_POST = "POST"; |
||
23 | const CURL_TYPE_PUT = "PUT"; |
||
24 | const CURL_TYPE_GET = "GET"; |
||
25 | |||
26 | /** |
||
27 | * Request constructor. |
||
28 | * @param Getnet $credentials |
||
29 | * @throws Exception |
||
30 | */ |
||
31 | public function __construct(Getnet $credentials) |
||
39 | |||
40 | /** |
||
41 | * @param Getnet $credentials |
||
42 | * @return Getnet |
||
43 | * @throws Exception |
||
44 | */ |
||
45 | public function auth(Getnet $credentials) |
||
76 | |||
77 | /** |
||
78 | * start session for use |
||
79 | * |
||
80 | * @param Getnet $credentials |
||
81 | * @return boolean |
||
82 | */ |
||
83 | private function verifyAuthSession(Getnet $credentials) |
||
99 | |||
100 | /** |
||
101 | * @param Getnet $credentials |
||
102 | * @param $url_path |
||
103 | * @param string $method |
||
104 | * @param null $json |
||
105 | * @return mixed |
||
106 | * @throws Exception |
||
107 | */ |
||
108 | private function send(Getnet $credentials, $url_path, $method, $json = null) |
||
161 | |||
162 | /** |
||
163 | * Get request full url |
||
164 | * |
||
165 | * @param string $url_path |
||
166 | * @return string $url(config) + $url_path |
||
167 | */ |
||
168 | private function getFullUrl($url_path) |
||
176 | |||
177 | /** |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getBaseUrl() |
||
184 | |||
185 | /** |
||
186 | * @param Getnet $credentials |
||
187 | * @param $url_path |
||
188 | * @return mixed |
||
189 | * @throws Exception |
||
190 | */ |
||
191 | public function get(Getnet $credentials, $url_path) |
||
195 | |||
196 | /** |
||
197 | * @param Getnet $credentials |
||
198 | * @param string $url_path |
||
199 | * @param false|string $params |
||
200 | * @return mixed |
||
201 | * @throws Exception |
||
202 | */ |
||
203 | public function post(Getnet $credentials, $url_path, $params) |
||
207 | |||
208 | /** |
||
209 | * @param Getnet $credentials |
||
210 | * @param $url_path |
||
211 | * @param $params |
||
212 | * @return mixed |
||
213 | * @throws Exception |
||
214 | */ |
||
215 | public function put(Getnet $credentials, $url_path, $params) |
||
219 | } |
||
220 |