|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace StarfolkSoftware\Flutterwave\Concerns; |
| 4 | + |
| 5 | +use StarfolkSoftware\Flutterwave\HttpClient\Message\ResponseMediator; |
| 6 | + |
| 7 | +trait MiscellaneousEndpoints |
| 8 | +{ |
| 9 | + /** |
| 10 | + * Retrieve balances |
| 11 | + * |
| 12 | + * @param string $currency |
| 13 | + * @return array |
| 14 | + */ |
| 15 | + public function balances(string $currency = ''): array |
| 16 | + { |
| 17 | + $url = $currency ? "balances/{$currency}" : "balances"; |
| 18 | + |
| 19 | + $response = $this->getHttpClient()->get($url); |
| 20 | + |
| 21 | + return ResponseMediator::getContent($response); |
| 22 | + } |
| 23 | + |
| 24 | + /** |
| 25 | + * Resolves account details |
| 26 | + * |
| 27 | + * @param string $accountNumber |
| 28 | + * @param string $accountBank |
| 29 | + * @return array |
| 30 | + */ |
| 31 | + public function resolveAccount(string $accountNumber, string $accountBank): array |
| 32 | + { |
| 33 | + $response = $this->getHttpClient()->post("accounts/resolve", [ |
| 34 | + 'json' => json_encode([ |
| 35 | + 'account_number' => $accountNumber, |
| 36 | + 'account_bank' => $accountBank, |
| 37 | + ]) |
| 38 | + ]); |
| 39 | + |
| 40 | + return ResponseMediator::getContent($response); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Resolves bvn details |
| 45 | + * |
| 46 | + * @param string $bvn |
| 47 | + * @return array |
| 48 | + */ |
| 49 | + public function resolveBvn(string $bvn): array |
| 50 | + { |
| 51 | + $response = $this->getHttpClient()->get("kyc/bvns/{$bvn}"); |
| 52 | + |
| 53 | + return ResponseMediator::getContent($response); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * Resolves card bins |
| 58 | + * |
| 59 | + * @param int $bin |
| 60 | + * @return array |
| 61 | + */ |
| 62 | + public function resolveCardBin(int $bin): array |
| 63 | + { |
| 64 | + $response = $this->getHttpClient()->get("card-bins/{$bin}"); |
| 65 | + |
| 66 | + return ResponseMediator::getContent($response); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Fetch FX rates |
| 71 | + * |
| 72 | + * @param string $from |
| 73 | + * @param string $to |
| 74 | + * @param int $amount |
| 75 | + * @return array |
| 76 | + */ |
| 77 | + public function fxRates(string $from, string $to, int $amount): array |
| 78 | + { |
| 79 | + $response = $this->getHttpClient()->get("rates", [ |
| 80 | + 'query' => json_encode([ |
| 81 | + 'from' => $from, |
| 82 | + 'to' => $to, |
| 83 | + 'amount' => $amount |
| 84 | + ]) |
| 85 | + ]); |
| 86 | + |
| 87 | + return ResponseMediator::getContent($response); |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Fetches wallet statement |
| 92 | + * |
| 93 | + * @param string $from |
| 94 | + * @param string $to |
| 95 | + * @param string $currency |
| 96 | + * @param string $type |
| 97 | + * @param int $page |
| 98 | + * @return array |
| 99 | + */ |
| 100 | + public function balanceHistory(string $from, string $to, string $currency, string $type = 'C', int $page = 1): array |
| 101 | + { |
| 102 | + $response = $this->getHttpClient()->get("wallet/statement", [ |
| 103 | + 'query' => json_encode([ |
| 104 | + 'from' => $from, |
| 105 | + 'to' => $to, |
| 106 | + 'currency' => $currency, |
| 107 | + 'type' => $type, |
| 108 | + 'page' => $page |
| 109 | + ]) |
| 110 | + ]); |
| 111 | + |
| 112 | + return ResponseMediator::getContent($response); |
| 113 | + } |
| 114 | +} |
0 commit comments