@@ 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. |
|
@@ 345-370 (lines=26) @@ | ||
342 | * |
|
343 | * @return array |
|
344 | */ |
|
345 | public function products($id) |
|
346 | { |
|
347 | try { |
|
348 | $response = $this->get( |
|
349 | sprintf( |
|
350 | '/webservice/smartload/products/%d', |
|
351 | $id |
|
352 | ), |
|
353 | [ |
|
354 | 'headers' => [ |
|
355 | 'Authorization' => $this->bearerOrBasic(), |
|
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 | * Authenticate and recharge request. |
|
@@ 427-452 (lines=26) @@ | ||
424 | * |
|
425 | * @return array |
|
426 | */ |
|
427 | public function registered($dealerMsisdn) |
|
428 | { |
|
429 | try { |
|
430 | $response = $this->get( |
|
431 | sprintf( |
|
432 | '/webservice/smartload/registered/%s', |
|
433 | $dealerMsisdn |
|
434 | ), |
|
435 | [ |
|
436 | 'headers' => [ |
|
437 | 'Authorization' => $this->bearerOrBasic(), |
|
438 | ], |
|
439 | ] |
|
440 | ); |
|
441 | ||
442 | return [ |
|
443 | 'status' => 'ok', |
|
444 | 'http_code' => $response->getStatusCode(), |
|
445 | 'body' => (string) $response->getBody(), |
|
446 | ]; |
|
447 | } catch (\GuzzleHttp\Exception\ClientException $e) { |
|
448 | return $this->clientError($e); |
|
449 | } catch (\GuzzleHttp\Exception\ServerException $e) { |
|
450 | return $this->parseError($e); |
|
451 | } |
|
452 | } |
|
453 | } |
|
454 |
@@ 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 |