@@ 7-58 (lines=52) @@ | ||
4 | ||
5 | use Bunq\BunqClient; |
|
6 | ||
7 | final class CardResource |
|
8 | { |
|
9 | /** |
|
10 | * @var BunqClient |
|
11 | */ |
|
12 | private $client; |
|
13 | ||
14 | /** |
|
15 | * @param BunqClient $client |
|
16 | */ |
|
17 | public function __construct(BunqClient $client) |
|
18 | { |
|
19 | $this->client = $client; |
|
20 | } |
|
21 | ||
22 | /** |
|
23 | * Lists all cards of the user. |
|
24 | * |
|
25 | * @param integer $userId |
|
26 | * |
|
27 | * @return array |
|
28 | */ |
|
29 | public function listCards($userId) |
|
30 | { |
|
31 | return $this->client->get($this->getResourceEndpoint($userId)); |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * Gets a user its card information. |
|
36 | * |
|
37 | * @param integer $userId |
|
38 | * @param integer $cardId |
|
39 | * |
|
40 | * @return array |
|
41 | */ |
|
42 | public function getCard($userId, $cardId) |
|
43 | { |
|
44 | $card = $this->client->get($this->getResourceEndpoint($userId) . '/' . (int)$cardId); |
|
45 | ||
46 | return $card['Response'][0]; |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * @param integer $userId |
|
51 | * |
|
52 | * @return string |
|
53 | */ |
|
54 | private function getResourceEndpoint($userId) |
|
55 | { |
|
56 | return '/v1/user/' . (int)$userId . '/card'; |
|
57 | } |
|
58 | } |
|
59 |
@@ 7-58 (lines=52) @@ | ||
4 | ||
5 | use Bunq\BunqClient; |
|
6 | ||
7 | final class MonetaryAccountResource |
|
8 | { |
|
9 | /** |
|
10 | * @var BunqClient |
|
11 | */ |
|
12 | private $client; |
|
13 | ||
14 | /** |
|
15 | * @param BunqClient $client |
|
16 | */ |
|
17 | public function __construct(BunqClient $client) |
|
18 | { |
|
19 | $this->client = $client; |
|
20 | } |
|
21 | ||
22 | /** |
|
23 | * Lists all the Monetary accounts for the current user. |
|
24 | * |
|
25 | * @param integer $userId |
|
26 | * |
|
27 | * @return array |
|
28 | */ |
|
29 | public function listMonetaryAccounts($userId) |
|
30 | { |
|
31 | $monetaryAccounts = $this->client->get($this->getResourceEndpoint($userId)); |
|
32 | ||
33 | return $monetaryAccounts; |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * Gets a Monetary Account by its identifier. |
|
38 | * |
|
39 | * @param integer $userId |
|
40 | * @param integer $id |
|
41 | * |
|
42 | * @return array |
|
43 | */ |
|
44 | public function getMonetaryAccount($userId, $id) |
|
45 | { |
|
46 | $monetaryAccount = $this->client->get($this->getResourceEndpoint($userId) . '/' . (int)$id); |
|
47 | ||
48 | return $monetaryAccount['Response'][0]['MonetaryAccountBank']; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * {@inheritdoc} |
|
53 | */ |
|
54 | private function getResourceEndpoint($userId) |
|
55 | { |
|
56 | return '/v1/user/' . (int) $userId . '/monetary-account'; |
|
57 | } |
|
58 | } |
|
59 |