1 | <?php |
||
16 | class Authenticator |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $endpoint; |
||
23 | /** |
||
24 | * @var Core |
||
25 | */ |
||
26 | protected $engine; |
||
27 | /** |
||
28 | * @var Authenticator |
||
29 | */ |
||
30 | protected static $instance; |
||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | public $alt = false; |
||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $credentials; |
||
39 | |||
40 | /** |
||
41 | * Authenticator constructor. |
||
42 | * |
||
43 | * @param Core $core |
||
44 | * @throws MpesaException |
||
45 | */ |
||
46 | 2 | public function __construct(Core $core) |
|
52 | |||
53 | /** |
||
54 | * @param bool $bulk |
||
55 | * @return string |
||
56 | * @throws MpesaException |
||
57 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
58 | */ |
||
59 | 1 | public function authenticate($bulk = false): ?string |
|
84 | |||
85 | /** |
||
86 | * @param $reason |
||
87 | * @return MpesaException |
||
88 | */ |
||
89 | private function generateException($reason): ?MpesaException |
||
98 | |||
99 | /** |
||
100 | * @return $this |
||
101 | */ |
||
102 | 1 | private function generateCredentials(): self |
|
114 | |||
115 | /** |
||
116 | * @return ResponseInterface |
||
117 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
118 | */ |
||
119 | 1 | private function makeRequest(): ResponseInterface |
|
132 | |||
133 | /** |
||
134 | * @return mixed |
||
135 | */ |
||
136 | 1 | private function getFromCache() |
|
140 | |||
141 | /** |
||
142 | * Store the credentials in the cache. |
||
143 | * |
||
144 | * @param $credentials |
||
145 | */ |
||
146 | private function saveCredentials($credentials) |
||
150 | } |
||
151 |