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