1 | <?php |
||
14 | class Bankly |
||
15 | { |
||
16 | public $api_url; |
||
17 | public $login_url; |
||
18 | private $client_id; |
||
19 | private $client_secret; |
||
20 | private $token_expiry = 0; |
||
21 | private $token = null; |
||
22 | private $api_version = '1.0'; |
||
23 | |||
24 | /** |
||
25 | * Bankly constructor. |
||
26 | * @param null|string $client_secret provided by Bankly Staff |
||
27 | * @param null|string $client_id provided by Bankly Staff |
||
28 | */ |
||
29 | public function __construct($client_secret = null, $client_id = null) |
||
35 | |||
36 | /** |
||
37 | * @param array|null $credentials |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function setClientCredentials(array $credentials = null) |
||
46 | |||
47 | /** |
||
48 | * @return array|mixed |
||
49 | * @throws RequestException |
||
50 | */ |
||
51 | final public function getBankList() |
||
55 | |||
56 | /** |
||
57 | * @param string $account |
||
58 | * @return array|mixed |
||
59 | * @throws RequestException |
||
60 | */ |
||
61 | final public function getBalance(string $account) |
||
66 | |||
67 | /** |
||
68 | * @param string $account |
||
69 | * @param string $includeBalance |
||
70 | * @return array|mixed |
||
71 | * @throws RequestException |
||
72 | */ |
||
73 | final public function getAccount(string $account, string $includeBalance = 'true') |
||
79 | |||
80 | /** |
||
81 | * @param $branch |
||
82 | * @param $account |
||
83 | * @param int $offset |
||
84 | * @param int $limit |
||
85 | * @param string $details |
||
86 | * @param string $detailsLevelBasic |
||
87 | * @return array|mixed |
||
88 | * @throws RequestException |
||
89 | */ |
||
90 | final public function getStatement( |
||
107 | |||
108 | /** |
||
109 | * @param string $branch |
||
110 | * @param string $account |
||
111 | * @param int $page |
||
112 | * @param int $pagesize |
||
113 | * @param string $include_details |
||
114 | * @return array|mixed |
||
115 | * @throws RequestException |
||
116 | */ |
||
117 | public function getEvents( |
||
135 | |||
136 | /** |
||
137 | * @param int $amount |
||
138 | * @param string $description |
||
139 | * @param array $sender |
||
140 | * @param array $recipient |
||
141 | * @param string|null $correlation_id |
||
142 | * @return array|mixed |
||
143 | * @throws RequestException |
||
144 | */ |
||
145 | public function transfer( |
||
168 | |||
169 | /** |
||
170 | * Get transfer funds from an account |
||
171 | * @param string $branch |
||
172 | * @param string $account |
||
173 | * @param int $pageSize |
||
174 | * @param string|null $nextPage |
||
175 | * @return array|mixed |
||
176 | * @throws RequestException |
||
177 | */ |
||
178 | public function getTransferFunds(string $branch, string $account, int $pageSize = 10, string $nextPage = null) |
||
190 | |||
191 | /** |
||
192 | * Get Transfer Funds By Authentication Code |
||
193 | * @param string $branch |
||
194 | * @param string $account |
||
195 | * @param string $authenticationCode |
||
196 | * @return array|mixed |
||
197 | * @throws RequestException |
||
198 | */ |
||
199 | public function findTransferFundByAuthCode(string $branch, string $account, string $authenticationCode) |
||
207 | |||
208 | /** |
||
209 | * @param string $branch |
||
210 | * @param string $account |
||
211 | * @param string $authentication_id |
||
212 | * @return array|mixed |
||
213 | * @throws RequestException |
||
214 | */ |
||
215 | public function getTransferStatus(string $branch, string $account, string $authentication_id) |
||
222 | |||
223 | /** |
||
224 | * @param string $endpoint |
||
225 | * @param array|null $query |
||
226 | * @param null $correlation_id |
||
227 | * @return array|mixed |
||
228 | * @throws RequestException |
||
229 | */ |
||
230 | private function get(string $endpoint, array $query = null, $correlation_id = null) |
||
246 | |||
247 | /** |
||
248 | * @param string $endpoint |
||
249 | * @param array|null $body |
||
250 | * @param string|null $correlation_id |
||
251 | * @param bool $asJson |
||
252 | * @return array|mixed |
||
253 | * @throws RequestException |
||
254 | */ |
||
255 | private function post(string $endpoint, array $body = null, string $correlation_id = null, bool $asJson = false) |
||
275 | |||
276 | /** |
||
277 | * @param string $version API version |
||
278 | * @return $this |
||
279 | */ |
||
280 | private function setApiVersion($version = '1.0') |
||
285 | |||
286 | /** |
||
287 | * @param array $headers |
||
288 | * @return array|string[] |
||
289 | */ |
||
290 | final private function getHeaders($headers = []) |
||
302 | |||
303 | /** |
||
304 | * @param string $endpoint |
||
305 | * @return bool |
||
306 | */ |
||
307 | final private function requireCorrelationId(string $endpoint) |
||
316 | |||
317 | /** |
||
318 | * @param string $endpoint |
||
319 | * @return string |
||
320 | */ |
||
321 | final private function getFinalUrl(string $endpoint) |
||
325 | |||
326 | /** |
||
327 | * Do authentication |
||
328 | * @param string $grant_type Default sets to 'client_credentials' |
||
329 | * @throws RequestException |
||
330 | */ |
||
331 | private function auth($grant_type = 'client_credentials'): void |
||
344 | } |
||
345 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: