@@ 107-129 (lines=23) @@ | ||
104 | * |
|
105 | * @return array |
|
106 | */ |
|
107 | public function auth() |
|
108 | { |
|
109 | try { |
|
110 | $response = $this->post( |
|
111 | '/webservice/auth', |
|
112 | [ |
|
113 | 'headers' => [ |
|
114 | 'Authorization' => $this->bearerOrBasic(), |
|
115 | ], |
|
116 | ] |
|
117 | ); |
|
118 | ||
119 | return [ |
|
120 | 'status' => 'ok', |
|
121 | 'http_code' => $response->getStatusCode(), |
|
122 | 'body' => (string) $response->getBody(), |
|
123 | ]; |
|
124 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
125 | return $this->clientError($e); |
|
126 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
127 | return $this->parseError($e); |
|
128 | } |
|
129 | } |
|
130 | ||
131 | /** |
|
132 | * Authenticate and invalidates all the user allocated tokens. |
|
@@ 138-160 (lines=23) @@ | ||
135 | * |
|
136 | * @return array |
|
137 | */ |
|
138 | public function authDelete() |
|
139 | { |
|
140 | try { |
|
141 | $response = $this->delete( |
|
142 | '/webservice/auth', |
|
143 | [ |
|
144 | 'headers' => [ |
|
145 | 'Authorization' => $this->bearerOrBasic(), |
|
146 | ], |
|
147 | ] |
|
148 | ); |
|
149 | ||
150 | return [ |
|
151 | 'status' => 'ok', |
|
152 | 'http_code' => $response->getStatusCode(), |
|
153 | 'body' => (string) $response->getBody(), |
|
154 | ]; |
|
155 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
156 | return $this->clientError($e); |
|
157 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
158 | return $this->parseError($e); |
|
159 | } |
|
160 | } |
|
161 | ||
162 | /** |
|
163 | * Authenticate and invalidates all the user allocated tokens. |
|
@@ 169-191 (lines=23) @@ | ||
166 | * |
|
167 | * @return array |
|
168 | */ |
|
169 | public function authFlush() |
|
170 | { |
|
171 | try { |
|
172 | $response = $this->delete( |
|
173 | '/webservice/auth/token', |
|
174 | [ |
|
175 | 'headers' => [ |
|
176 | 'Authorization' => $this->bearerOrBasic(), |
|
177 | ], |
|
178 | ] |
|
179 | ); |
|
180 | ||
181 | return [ |
|
182 | 'status' => 'ok', |
|
183 | 'http_code' => $response->getStatusCode(), |
|
184 | 'body' => (string) $response->getBody(), |
|
185 | ]; |
|
186 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
187 | return $this->clientError($e); |
|
188 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
189 | return $this->parseError($e); |
|
190 | } |
|
191 | } |
|
192 | ||
193 | /** |
|
194 | * Authenticate and gets the number of available session tokens. |
|
@@ 200-222 (lines=23) @@ | ||
197 | * |
|
198 | * @return array |
|
199 | */ |
|
200 | public function authToken() |
|
201 | { |
|
202 | try { |
|
203 | $response = $this->get( |
|
204 | '/webservice/auth/token', |
|
205 | [ |
|
206 | 'headers' => [ |
|
207 | 'Authorization' => $this->bearerOrBasic(), |
|
208 | ], |
|
209 | ] |
|
210 | ); |
|
211 | ||
212 | return [ |
|
213 | 'status' => 'ok', |
|
214 | 'http_code' => $response->getStatusCode(), |
|
215 | 'body' => (string) $response->getBody(), |
|
216 | ]; |
|
217 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
218 | return $this->clientError($e); |
|
219 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
220 | return $this->parseError($e); |
|
221 | } |
|
222 | } |
|
223 | ||
224 | /** |
|
225 | * Test SmartCall is responding. |
@@ 26-51 (lines=26) @@ | ||
23 | * |
|
24 | * @return array |
|
25 | */ |
|
26 | public function balance($dealerMsisdn) |
|
27 | { |
|
28 | try { |
|
29 | $response = $this->get( |
|
30 | sprintf( |
|
31 | '/webservice/smartload/balance/%s', |
|
32 | $dealerMsisdn |
|
33 | ), |
|
34 | [ |
|
35 | 'headers' => [ |
|
36 | 'Authorization' => $this->bearerOrBasic(), |
|
37 | ], |
|
38 | ] |
|
39 | ); |
|
40 | ||
41 | return [ |
|
42 | 'status' => 'ok', |
|
43 | 'http_code' => $response->getStatusCode(), |
|
44 | 'body' => (string) $response->getBody(), |
|
45 | ]; |
|
46 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
47 | return $this->clientError($e); |
|
48 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
49 | return $this->parseError($e); |
|
50 | } |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * Authenticate and request to cancel a previous recharge request. Will only |
|
@@ 64-90 (lines=27) @@ | ||
61 | * |
|
62 | * @return array |
|
63 | */ |
|
64 | public function cancelRecharge($dealerMsisdn, $clientReference) |
|
65 | { |
|
66 | try { |
|
67 | $response = $this->delete( |
|
68 | sprintf( |
|
69 | '/webservice/smartload/recharges/%s/%s', |
|
70 | $dealerMsisdn, |
|
71 | $clientReference |
|
72 | ), |
|
73 | [ |
|
74 | 'headers' => [ |
|
75 | 'Authorization' => $this->bearerOrBasic(), |
|
76 | ], |
|
77 | ] |
|
78 | ); |
|
79 | ||
80 | return [ |
|
81 | 'status' => 'ok', |
|
82 | 'http_code' => $response->getStatusCode(), |
|
83 | 'body' => (string) $response->getBody(), |
|
84 | ]; |
|
85 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
86 | return $this->clientError($e); |
|
87 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
88 | return $this->parseError($e); |
|
89 | } |
|
90 | } |
|
91 | ||
92 | /** |
|
93 | * Authenticate and request period based cashup reports. |
|
@@ 141-166 (lines=26) @@ | ||
138 | * |
|
139 | * @return array |
|
140 | */ |
|
141 | public function cashupToday($dealerMsisdn) |
|
142 | { |
|
143 | try { |
|
144 | $response = $this->get( |
|
145 | sprintf( |
|
146 | '/webservice/smartload/cashup/%s', |
|
147 | $dealerMsisdn |
|
148 | ), |
|
149 | [ |
|
150 | 'headers' => [ |
|
151 | 'Authorization' => $this->bearerOrBasic(), |
|
152 | ], |
|
153 | ] |
|
154 | ); |
|
155 | ||
156 | return [ |
|
157 | 'status' => 'ok', |
|
158 | 'http_code' => $response->getStatusCode(), |
|
159 | 'body' => (string) $response->getBody(), |
|
160 | ]; |
|
161 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
162 | return $this->clientError($e); |
|
163 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
164 | return $this->parseError($e); |
|
165 | } |
|
166 | } |
|
167 | ||
168 | /** |
|
169 | * Authenticate and request to transfer funds from one Smartload account to another. |
|
@@ 217-242 (lines=26) @@ | ||
214 | * |
|
215 | * @return array |
|
216 | */ |
|
217 | public function network($id) |
|
218 | { |
|
219 | try { |
|
220 | $response = $this->get( |
|
221 | sprintf( |
|
222 | '/webservice/smartload/networks/%d', |
|
223 | $id |
|
224 | ), |
|
225 | [ |
|
226 | 'headers' => [ |
|
227 | 'Authorization' => $this->bearerOrBasic(), |
|
228 | ], |
|
229 | ] |
|
230 | ); |
|
231 | ||
232 | return [ |
|
233 | 'status' => 'ok', |
|
234 | 'http_code' => $response->getStatusCode(), |
|
235 | 'body' => (string) $response->getBody(), |
|
236 | ]; |
|
237 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
238 | return $this->clientError($e); |
|
239 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
240 | return $this->parseError($e); |
|
241 | } |
|
242 | } |
|
243 | ||
244 | /** |
|
245 | * Authenticate and retrieves a list of all available networks. |
|
@@ 251-273 (lines=23) @@ | ||
248 | * |
|
249 | * @return array |
|
250 | */ |
|
251 | public function networks() |
|
252 | { |
|
253 | try { |
|
254 | $response = $this->get( |
|
255 | '/webservice/smartload/networks', |
|
256 | [ |
|
257 | 'headers' => [ |
|
258 | 'Authorization' => $this->bearerOrBasic(), |
|
259 | ], |
|
260 | ] |
|
261 | ); |
|
262 | ||
263 | return [ |
|
264 | 'status' => 'ok', |
|
265 | 'http_code' => $response->getStatusCode(), |
|
266 | 'body' => (string) $response->getBody(), |
|
267 | ]; |
|
268 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
269 | return $this->clientError($e); |
|
270 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
271 | return $this->parseError($e); |
|
272 | } |
|
273 | } |
|
274 | ||
275 | /** |
|
276 | * Authenticate and recharge prevend request. |
|
@@ 330-355 (lines=26) @@ | ||
327 | * |
|
328 | * @return array |
|
329 | */ |
|
330 | public function products($id) |
|
331 | { |
|
332 | try { |
|
333 | $response = $this->get( |
|
334 | sprintf( |
|
335 | '/webservice/smartload/products/%d', |
|
336 | $id |
|
337 | ), |
|
338 | [ |
|
339 | 'headers' => [ |
|
340 | 'Authorization' => $this->bearerOrBasic(), |
|
341 | ], |
|
342 | ] |
|
343 | ); |
|
344 | ||
345 | return [ |
|
346 | 'status' => 'ok', |
|
347 | 'http_code' => $response->getStatusCode(), |
|
348 | 'body' => (string) $response->getBody(), |
|
349 | ]; |
|
350 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
351 | return $this->clientError($e); |
|
352 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
353 | return $this->parseError($e); |
|
354 | } |
|
355 | } |
|
356 | ||
357 | /** |
|
358 | * Authenticate and recharge request. |
|
@@ 412-437 (lines=26) @@ | ||
409 | * |
|
410 | * @return array |
|
411 | */ |
|
412 | public function registered($dealerMsisdn) |
|
413 | { |
|
414 | try { |
|
415 | $response = $this->get( |
|
416 | sprintf( |
|
417 | '/webservice/smartload/registered/%s', |
|
418 | $dealerMsisdn |
|
419 | ), |
|
420 | [ |
|
421 | 'headers' => [ |
|
422 | 'Authorization' => $this->bearerOrBasic(), |
|
423 | ], |
|
424 | ] |
|
425 | ); |
|
426 | ||
427 | return [ |
|
428 | 'status' => 'ok', |
|
429 | 'http_code' => $response->getStatusCode(), |
|
430 | 'body' => (string) $response->getBody(), |
|
431 | ]; |
|
432 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
433 | return $this->clientError($e); |
|
434 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
435 | return $this->parseError($e); |
|
436 | } |
|
437 | } |
|
438 | ||
439 | /** |
|
440 | * Authenticate and retrieves the details of the transaction that was performed |
|
@@ 446-472 (lines=27) @@ | ||
443 | * @param string $dealerMsisdn |
|
444 | * @param string $clientReference |
|
445 | */ |
|
446 | public function transaction($dealerMsisdn, $clientReference) |
|
447 | { |
|
448 | try { |
|
449 | $response = $this->get( |
|
450 | sprintf( |
|
451 | '/webservice/smartload/recharges/%s/%s', |
|
452 | $dealerMsisdn, |
|
453 | $clientReference |
|
454 | ), |
|
455 | [ |
|
456 | 'headers' => [ |
|
457 | 'Authorization' => $this->bearerOrBasic(), |
|
458 | ], |
|
459 | ] |
|
460 | ); |
|
461 | ||
462 | return [ |
|
463 | 'status' => 'ok', |
|
464 | 'http_code' => $response->getStatusCode(), |
|
465 | 'body' => (string) $response->getBody(), |
|
466 | ]; |
|
467 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
468 | return $this->clientError($e); |
|
469 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
470 | return $this->parseError($e); |
|
471 | } |
|
472 | } |
|
473 | } |
|
474 |
@@ 55-77 (lines=23) @@ | ||
52 | } |
|
53 | } |
|
54 | ||
55 | public function registrations() |
|
56 | { |
|
57 | try { |
|
58 | $response = $this->post( |
|
59 | '/webservice/smartrica/registrations', |
|
60 | [ |
|
61 | 'headers' => [ |
|
62 | 'Authorization' => $this->bearerOrBasic(), |
|
63 | ], |
|
64 | ] |
|
65 | ); |
|
66 | ||
67 | return [ |
|
68 | 'status' => 'ok', |
|
69 | 'http_code' => $response->getStatusCode(), |
|
70 | 'body' => (string) $response->getBody(), |
|
71 | ]; |
|
72 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
73 | return $this->clientError($e); |
|
74 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
75 | return $this->parseError($e); |
|
76 | } |
|
77 | } |
|
78 | } |
|
79 |