File tree 3 files changed +118
-4
lines changed
3 files changed +118
-4
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Dotenv \Dotenv ;
4
+ use GuzzleHttp \Exception \RequestException ;
5
+ use LJJackson \Volt \Exceptions \PaymentValidationException ;
6
+ use LJJackson \Volt \VoltApi ;
7
+ use LJJackson \Volt \VoltApiConfig ;
8
+
9
+ require __DIR__ . '/../vendor/autoload.php ' ;
10
+
11
+ $ dotenv = Dotenv::createImmutable (__DIR__ );
12
+ $ dotenv ->load ();
13
+
14
+ $ config = new VoltApiConfig (
15
+ $ _ENV ['VOLT_CLIENT_ID ' ],
16
+ $ _ENV ['VOLT_CLIENT_SECRET ' ],
17
+ $ _ENV ['VOLT_API_USERNAME ' ],
18
+ $ _ENV ['VOLT_API_PASSWORD ' ]
19
+ );
20
+
21
+ $ config ->setSandbox ();
22
+
23
+ $ api = new VoltApi ($ config );
24
+
25
+ $ accessToken = $ api ->authentication ->authenticate ();
26
+
27
+ $ banks = $ api ->banks ->retrieveAll ($ accessToken );
28
+
29
+ var_dump ($ banks [0 ]);
30
+
31
+
32
+
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+
4
+ namespace LJJackson \Volt \Entities ;
5
+
6
+
7
+ class Bank
8
+ {
9
+ private string $ id ;
10
+ private string $ name ;
11
+ private string $ country ;
12
+ private string $ logo ;
13
+ private string $ icon ;
14
+ private array $ currencies ;
15
+ private array $ providers ;
16
+
17
+ public function __construct (array $ response )
18
+ {
19
+ $ this ->id = $ response ['id ' ];
20
+ $ this ->name = $ response ['name ' ];
21
+ $ this ->country = $ response ['country ' ]['id ' ];
22
+ $ this ->logo = $ response ['logo ' ];
23
+ $ this ->icon = $ response ['icon ' ];
24
+ $ this ->currencies = $ response ['supportedCurrencies ' ];
25
+ $ this ->providers = $ response ['providedBy ' ] ?? [];
26
+ }
27
+
28
+ /**
29
+ * @return string
30
+ */
31
+ public function getId (): string
32
+ {
33
+ return $ this ->id ;
34
+ }
35
+
36
+ /**
37
+ * @return string
38
+ */
39
+ public function getName (): string
40
+ {
41
+ return $ this ->name ;
42
+ }
43
+
44
+ /**
45
+ * @return string
46
+ */
47
+ public function getCountry (): string
48
+ {
49
+ return $ this ->country ;
50
+ }
51
+
52
+ /**
53
+ * @return string
54
+ */
55
+ public function getLogo (): string
56
+ {
57
+ return $ this ->logo ;
58
+ }
59
+
60
+ /**
61
+ * @return string
62
+ */
63
+ public function getIcon (): string
64
+ {
65
+ return $ this ->icon ;
66
+ }
67
+
68
+ /**
69
+ * @return string[]
70
+ */
71
+ public function getCurrencies (): array
72
+ {
73
+ return $ this ->currencies ;
74
+ }
75
+
76
+ /**
77
+ * @return string[]
78
+ */
79
+ public function getProviders (): array
80
+ {
81
+ return $ this ->providers ;
82
+ }
83
+ }
Original file line number Diff line number Diff line change 6
6
7
7
use GuzzleHttp \RequestOptions ;
8
8
use LJJackson \Volt \Entities \AccessToken ;
9
+ use LJJackson \Volt \Entities \Bank ;
9
10
10
11
class BankService extends BaseService
11
12
{
12
13
/**
13
- * TODO Create entity.
14
- *
15
14
* @param AccessToken $token
16
- * @return mixed
15
+ * @return Bank[]
17
16
* @throws \GuzzleHttp\Exception\GuzzleException
18
17
*/
19
18
public function retrieveAll (AccessToken $ token )
@@ -26,6 +25,6 @@ public function retrieveAll(AccessToken $token)
26
25
27
26
$ results = json_decode ($ response ->getBody ()->getContents (), true );
28
27
29
- return $ results ;
28
+ return array_map ( fn ( $ bank ) => new Bank ( $ bank ), $ results) ;
30
29
}
31
30
}
You can’t perform that action at this time.
0 commit comments