1 | <?php |
||
2 | |||
3 | namespace Digikraaft\Mono; |
||
4 | |||
5 | use Digikraaft\Mono\Util\Util; |
||
6 | |||
7 | class Account extends ApiResource |
||
8 | { |
||
9 | const OBJECT_NAME = 'accounts'; |
||
10 | |||
11 | /** |
||
12 | * @param string $authCode |
||
13 | * |
||
14 | * @return array|object |
||
15 | * @throws Exceptions\InvalidArgumentException |
||
16 | * @throws Exceptions\IsNullException |
||
17 | * @link https://docs.mono.co/reference#authentication-endpoint |
||
18 | */ |
||
19 | public static function authenticate(string $authCode) |
||
20 | { |
||
21 | $url = "account/auth"; |
||
22 | |||
23 | return static::staticRequest('POST', $url, ['code' => $authCode]); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param string $accountId |
||
28 | * @return array|object |
||
29 | * @throws Exceptions\InvalidArgumentException |
||
30 | * @throws Exceptions\IsNullException |
||
31 | * @link https://docs.mono.co/reference#bank-account-details |
||
32 | */ |
||
33 | public static function details(string $accountId) |
||
34 | { |
||
35 | $url = self::endPointUrl("{$accountId}"); |
||
36 | |||
37 | return self::staticRequest('GET', $url); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param string $accountId |
||
42 | * @param array $filters |
||
43 | * |
||
44 | * @return array|object |
||
45 | * @throws Exceptions\InvalidArgumentException |
||
46 | * @throws Exceptions\IsNullException |
||
47 | * @link https://docs.mono.co/reference#bank-statement |
||
48 | */ |
||
49 | public static function fetchStatement(string $accountId, array $filters) |
||
50 | { |
||
51 | Util::validateData(['period'], $filters); |
||
52 | $url = static::buildQueryString("{$accountId}/statement", $filters); |
||
53 | |||
54 | return static::staticRequest('GET', $url); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param string $accountId |
||
59 | * @param string $jobId |
||
60 | * @return array|object |
||
61 | * @throws Exceptions\InvalidArgumentException |
||
62 | * @throws Exceptions\IsNullException |
||
63 | * @link https://docs.mono.co/reference#poll-statement-status |
||
64 | */ |
||
65 | public static function pollStatementPdfStatus(string $accountId, string $jobId) |
||
66 | { |
||
67 | $url = self::endPointUrl("{$accountId}/statement/jobs/$jobId"); |
||
68 | |||
69 | return static::staticRequest('GET', $url); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @param string $accountId |
||
74 | * @param array|null $filters |
||
75 | * |
||
76 | * @return array|object |
||
77 | * @throws Exceptions\InvalidArgumentException |
||
78 | * @throws Exceptions\IsNullException |
||
79 | * @link https://docs.mono.co/reference#transactions |
||
80 | */ |
||
81 | public static function listTransactions(string $accountId, ?array $filters = null) |
||
82 | { |
||
83 | $url = static::buildQueryString("{$accountId}/transactions", $filters); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
84 | |||
85 | return static::staticRequest('GET', $url); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param string $accountId |
||
90 | * @return array|object |
||
91 | * @throws Exceptions\InvalidArgumentException |
||
92 | * @throws Exceptions\IsNullException |
||
93 | * @link https://docs.mono.co/reference#income |
||
94 | */ |
||
95 | public static function income(string $accountId) |
||
96 | { |
||
97 | $url = static::endPointUrl("{$accountId}/income"); |
||
98 | |||
99 | return static::staticRequest("GET", $url); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @param string $accountId |
||
104 | * @return array|object |
||
105 | * @throws Exceptions\InvalidArgumentException |
||
106 | * @throws Exceptions\IsNullException |
||
107 | * @link https://docs.mono.co/reference#identity |
||
108 | */ |
||
109 | public static function identity(string $accountId) |
||
110 | { |
||
111 | $url = static::endPointUrl("{$accountId}/identity"); |
||
112 | |||
113 | return static::staticRequest("GET", $url); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @param string $accountId |
||
118 | * @param array $params |
||
119 | * @return array|object |
||
120 | * @throws Exceptions\InvalidArgumentException |
||
121 | * @throws Exceptions\IsNullException |
||
122 | * @link https://docs.mono.co/reference#manually-trigger |
||
123 | */ |
||
124 | public static function sync(string $accountId, ?array $params = null) |
||
125 | { |
||
126 | $url = static::endPointUrl("{$accountId}/sync"); |
||
127 | |||
128 | return static::staticRequest("POST", $url, $params); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param string $accountId |
||
133 | * @param array|null $params |
||
134 | * @return array|object |
||
135 | * @throws Exceptions\InvalidArgumentException |
||
136 | * @throws Exceptions\IsNullException |
||
137 | * @link https://docs.mono.co/reference#reauth-code |
||
138 | */ |
||
139 | public static function reAuthorise(string $accountId, ?array $params = null) |
||
140 | { |
||
141 | $url = static::endPointUrl("{$accountId}/reauthorise"); |
||
142 | |||
143 | return static::staticRequest("POST", $url, $params); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @param null $params |
||
0 ignored issues
–
show
|
|||
148 | * @return array|object |
||
149 | * @throws Exceptions\InvalidArgumentException |
||
150 | * @throws Exceptions\IsNullException |
||
151 | * @link https://docs.mono.co/reference#bvnlookup |
||
152 | */ |
||
153 | public static function bvnLookup($params = null) |
||
154 | { |
||
155 | $url = "lookup/bvn/identity"; |
||
156 | |||
157 | return static::staticRequest('POST', $url, $params); |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * @param string $accountId |
||
162 | * @param array|null $params |
||
163 | * @return array|object |
||
164 | * @throws Exceptions\InvalidArgumentException |
||
165 | * @throws Exceptions\IsNullException |
||
166 | * @link https://docs.mono.co/reference#unlink-account |
||
167 | */ |
||
168 | public static function unlink(string $accountId, ?array $params = null) |
||
169 | { |
||
170 | $url = static::endPointUrl("{$accountId}/unlink"); |
||
171 | |||
172 | return static::staticRequest("POST", $url, $params); |
||
173 | } |
||
174 | } |
||
175 |