| @@ 117-136 (lines=20) @@ | ||
| 114 | return $this->resolveResponse($response); |
|
| 115 | } |
|
| 116 | ||
| 117 | public function generateToken($phone, $passcode, $factor = 'sms') |
|
| 118 | { |
|
| 119 | if (!in_array($factor, $this->factors)) { |
|
| 120 | throw new \Exception("Factor [$factor] not available. Available factors are: " . join(", ", $this->factors)); |
|
| 121 | } |
|
| 122 | ||
| 123 | try { |
|
| 124 | $response = $this->client->post('/v1/users/auth', [ |
|
| 125 | 'form_params' => [ |
|
| 126 | 'mobile' => $phone, |
|
| 127 | 'factor' => $factor, |
|
| 128 | 'passcode' => $passcode |
|
| 129 | ] |
|
| 130 | ]); |
|
| 131 | } catch (ClientException $e) { |
|
| 132 | return $this->handleException($e); |
|
| 133 | } |
|
| 134 | ||
| 135 | return $this->resolveResponse($response); |
|
| 136 | } |
|
| 137 | ||
| 138 | public function refreshToken($refreshToken) |
|
| 139 | { |
|
| @@ 192-213 (lines=22) @@ | ||
| 189 | return $this->resolveResponse($response); |
|
| 190 | } |
|
| 191 | ||
| 192 | public function vtu($walletToken, $mobile, $amount, $provider) |
|
| 193 | { |
|
| 194 | ||
| 195 | if (!in_array(strtolower($provider), $this->providers)) { |
|
| 196 | throw new \Exception("Provider [$provider] not supported. Supported providers are: " . join(",", $this->providers)); |
|
| 197 | } |
|
| 198 | ||
| 199 | try { |
|
| 200 | $response = $this->client->post('/v1/users/payments/bills/vtu', [ |
|
| 201 | 'headers' => ['X-App-Wallet-Access-Token' => $walletToken], |
|
| 202 | 'form_params' => [ |
|
| 203 | 'amount' => $amount, |
|
| 204 | 'mobile' => $mobile, |
|
| 205 | 'provider' => $provider |
|
| 206 | ] |
|
| 207 | ]); |
|
| 208 | } catch (ClientException $e) { |
|
| 209 | return $this->handleException($e); |
|
| 210 | } |
|
| 211 | ||
| 212 | return $this->resolveResponse($response); |
|
| 213 | } |
|
| 214 | ||
| 215 | public function balance($walletToken) |
|
| 216 | { |
|