Skip to content

Commit 9fa3ab9

Browse files
committed
update library
1 parent 9e86129 commit 9fa3ab9

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/Resources/Bank.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace Matscode\Paystack\Resources;
4+
5+
use GuzzleHttp\Exception\GuzzleException;
6+
use GuzzleHttp\Psr7;
7+
use GuzzleHttp\Exception\ClientException;
8+
use Matscode\Paystack\Exceptions\JsonException;
9+
use Matscode\Paystack\Interfaces\ResourceInterface;
10+
use Matscode\Paystack\Traits\ResourcePath;
11+
use Matscode\Paystack\Utility\Helpers;
12+
use Matscode\Paystack\Utility\HTTP\HTTPClient;
13+
use stdClass;
14+
15+
class Bank implements ResourceInterface
16+
{
17+
use ResourcePath;
18+
19+
protected $httpClient;
20+
21+
/**
22+
* @throws \Exception
23+
*/
24+
public function __construct(HTTPClient $HTTPClient)
25+
{
26+
$this->setBasePath('bank');
27+
28+
$this->httpClient = $HTTPClient;
29+
}
30+
31+
/**
32+
* List available bank information
33+
*
34+
* @link https://paystack.com/docs/api/#miscellaneous-bank
35+
*
36+
* @throws GuzzleException
37+
* @throws JsonException
38+
*/
39+
public function list(): stdClass
40+
{
41+
return Helpers::JSONStringToObj($this->httpClient->get($this->makePath())->getBody());
42+
}
43+
44+
/**
45+
* @param $bank_code
46+
* @param $account_number
47+
* @return stdClass
48+
* @throws GuzzleException
49+
* @throws JsonException
50+
*/
51+
public function resolve($bank_code, $account_number): StdClass
52+
{
53+
return Helpers::JSONStringToObj($this->httpClient->get($this->makePath('/resolve'), [
54+
'query' => [
55+
'bank_code' => $bank_code,
56+
'account_number' => $account_number,
57+
]
58+
])->getBody());
59+
}
60+
}

0 commit comments

Comments
 (0)