@@ 124-149 (lines=26) @@ | ||
121 | * |
|
122 | * @return array |
|
123 | */ |
|
124 | public function authDelete() |
|
125 | { |
|
126 | try { |
|
127 | $response = $this->delete( |
|
128 | '/webservice/auth', |
|
129 | [ |
|
130 | 'headers' => [ |
|
131 | 'Authorization' => sprintf( |
|
132 | 'Bearer %s', |
|
133 | $this->options['token'] |
|
134 | ), |
|
135 | ], |
|
136 | ] |
|
137 | ); |
|
138 | ||
139 | return [ |
|
140 | 'status' => 'ok', |
|
141 | 'http_code' => $response->getStatusCode(), |
|
142 | 'body' => (string) $response->getBody(), |
|
143 | ]; |
|
144 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
145 | return $this->clientError($e); |
|
146 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
147 | return $this->parseError($e); |
|
148 | } |
|
149 | } |
|
150 | ||
151 | /** |
|
152 | * Authenticate and invalidates all the user allocated tokens. |
|
@@ 271-299 (lines=29) @@ | ||
268 | * |
|
269 | * @return array |
|
270 | */ |
|
271 | public function cashupToday($dealerMsisdn) |
|
272 | { |
|
273 | try { |
|
274 | $response = $this->get( |
|
275 | sprintf( |
|
276 | '/webservice/smartload/cashup/%s', |
|
277 | $dealerMsisdn |
|
278 | ), |
|
279 | [ |
|
280 | 'headers' => [ |
|
281 | 'Authorization' => sprintf( |
|
282 | 'Bearer %s', |
|
283 | $this->options['token'] |
|
284 | ), |
|
285 | ], |
|
286 | ] |
|
287 | ); |
|
288 | ||
289 | return [ |
|
290 | 'status' => 'ok', |
|
291 | 'http_code' => $response->getStatusCode(), |
|
292 | 'body' => (string) $response->getBody(), |
|
293 | ]; |
|
294 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
295 | return $this->clientError($e); |
|
296 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
297 | return $this->parseError($e); |
|
298 | } |
|
299 | } |
|
300 | ||
301 | /** |
|
302 | * Authenticate and retrieves a list of all available networks. |
|
@@ 308-336 (lines=29) @@ | ||
305 | * |
|
306 | * @return array |
|
307 | */ |
|
308 | public function network($id) |
|
309 | { |
|
310 | try { |
|
311 | $response = $this->get( |
|
312 | sprintf( |
|
313 | '/webservice/smartload/networks/%d', |
|
314 | $id |
|
315 | ), |
|
316 | [ |
|
317 | 'headers' => [ |
|
318 | 'Authorization' => sprintf( |
|
319 | 'Bearer %s', |
|
320 | $this->options['token'] |
|
321 | ), |
|
322 | ], |
|
323 | ] |
|
324 | ); |
|
325 | ||
326 | return [ |
|
327 | 'status' => 'ok', |
|
328 | 'http_code' => $response->getStatusCode(), |
|
329 | 'body' => (string) $response->getBody(), |
|
330 | ]; |
|
331 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
332 | return $this->clientError($e); |
|
333 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
334 | return $this->parseError($e); |
|
335 | } |
|
336 | } |
|
337 | ||
338 | /** |
|
339 | * Authenticate and retrieves a list of all available networks. |
|
@@ 345-370 (lines=26) @@ | ||
342 | * |
|
343 | * @return array |
|
344 | */ |
|
345 | public function networks() |
|
346 | { |
|
347 | try { |
|
348 | $response = $this->get( |
|
349 | '/webservice/smartload/networks', |
|
350 | [ |
|
351 | 'headers' => [ |
|
352 | 'Authorization' => sprintf( |
|
353 | 'Bearer %s', |
|
354 | $this->options['token'] |
|
355 | ), |
|
356 | ], |
|
357 | ] |
|
358 | ); |
|
359 | ||
360 | return [ |
|
361 | 'status' => 'ok', |
|
362 | 'http_code' => $response->getStatusCode(), |
|
363 | 'body' => (string) $response->getBody(), |
|
364 | ]; |
|
365 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
366 | return $this->clientError($e); |
|
367 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
368 | return $this->parseError($e); |
|
369 | } |
|
370 | } |
|
371 | ||
372 | /** |
|
373 | * Test SmartCall is responding. |
|
@@ 405-433 (lines=29) @@ | ||
402 | * |
|
403 | * @return array |
|
404 | */ |
|
405 | public function products($id) |
|
406 | { |
|
407 | try { |
|
408 | $response = $this->get( |
|
409 | sprintf( |
|
410 | '/webservice/smartload/products/%d', |
|
411 | $id |
|
412 | ), |
|
413 | [ |
|
414 | 'headers' => [ |
|
415 | 'Authorization' => sprintf( |
|
416 | 'Bearer %s', |
|
417 | $this->options['token'] |
|
418 | ), |
|
419 | ], |
|
420 | ] |
|
421 | ); |
|
422 | ||
423 | return [ |
|
424 | 'status' => 'ok', |
|
425 | 'http_code' => $response->getStatusCode(), |
|
426 | 'body' => (string) $response->getBody(), |
|
427 | ]; |
|
428 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
429 | return $this->clientError($e); |
|
430 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
431 | return $this->parseError($e); |
|
432 | } |
|
433 | } |
|
434 | ||
435 | /** |
|
436 | * Parse the java exception that we receive from Smartcall's Tomcat's. |