|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace tbclla\Revolut\Resources; |
|
4
|
|
|
|
|
5
|
|
|
class Transaction extends Resource |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* The enpoint for transaction requests |
|
9
|
|
|
* |
|
10
|
|
|
* @var string |
|
11
|
|
|
*/ |
|
12
|
|
|
const ENDPOINT = '/transactions'; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Get up to 1000 historical transactions based on the provided query criteria |
|
16
|
|
|
* |
|
17
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transactions Official API documentation |
|
18
|
|
|
* @param array $filters accepts optional 'from', 'to', 'counterparty', 'count', type' |
|
19
|
|
|
* @param bool $useFreshToken Force the use of a new access token. |
|
20
|
|
|
* @return array The response body |
|
21
|
|
|
* @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
22
|
|
|
* @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
23
|
|
|
*/ |
|
24
|
|
|
public function all(array $filters = [], $useFreshToken = false) |
|
25
|
|
|
{ |
|
26
|
|
|
if ($useFreshToken) { |
|
27
|
|
|
$this->client->refreshAccessToken(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
return $this->client->get(self::ENDPOINT, ['query' => $filters]); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Get a transaction by its ID |
|
35
|
|
|
* |
|
36
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transaction Official API documentation |
|
37
|
|
|
* @param string $id The transaction ID in UUID format |
|
38
|
|
|
* @return array The response body |
|
39
|
|
|
* @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
40
|
|
|
* @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
41
|
|
|
*/ |
|
42
|
|
|
public function get(string $id) |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->client->get('/transaction/' . $id); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Get a transaction by its request ID |
|
49
|
|
|
* |
|
50
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#payments-get-transaction Official API documentation |
|
51
|
|
|
* @param string $requestId The request ID |
|
52
|
|
|
* @return array The response body |
|
53
|
|
|
* @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
|
54
|
|
|
* @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getByRequestId(string $requestId) |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->client->get('/transaction/' . $requestId, [ |
|
59
|
|
|
'query' => [ |
|
60
|
|
|
'id_type' => 'request_id' |
|
61
|
|
|
] |
|
62
|
|
|
]); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|