1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace tbclla\Revolut\Resources; |
4
|
|
|
|
5
|
|
|
use tbclla\Revolut\Builders\CounterpartyBuilder; |
6
|
|
|
use tbclla\Revolut\Interfaces\Buildable; |
7
|
|
|
|
8
|
|
|
class Counterparty extends Resource implements Buildable |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* The enpoint for counterparty requests |
12
|
|
|
* |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
const ENDPOINT = '/counterparty'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-add-revolut-counterparty Official API documentation |
19
|
|
|
*/ |
20
|
|
|
public function create(array $json) |
21
|
|
|
{ |
22
|
|
|
return $this->client->post(self::ENDPOINT, ['json' => $json]); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Get all counterparties |
27
|
|
|
* |
28
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-get-counterparties Official API documentation |
29
|
|
|
* @return array The response body |
30
|
|
|
* @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
31
|
|
|
* @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
32
|
|
|
*/ |
33
|
|
|
public function all() |
34
|
|
|
{ |
35
|
|
|
return $this->client->get('/counterparties'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Get a counterparty by its ID |
40
|
|
|
* |
41
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-get-counterparty Official API documentation |
42
|
|
|
* @param string $id The counterpary ID in UUID format |
43
|
|
|
* @return array The response body |
44
|
|
|
* @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
45
|
|
|
* @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
46
|
|
|
*/ |
47
|
|
|
public function get(string $id) |
48
|
|
|
{ |
49
|
|
|
return $this->client->get(self::ENDPOINT . '/' . $id); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Delete a counterparty by its ID |
54
|
|
|
* |
55
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#counterparties-delete-counterparty Official API documentation |
56
|
|
|
* @param string $id The counterpary ID in UUID format |
57
|
|
|
* @return void |
58
|
|
|
* @throws \tbclla\Revolut\Exceptions\ApiException if the client responded with a 4xx-5xx response |
59
|
|
|
* @throws \tbclla\Revolut\Exceptions\AppUnauthorizedException if the app needs to be re-authorized |
60
|
|
|
*/ |
61
|
|
|
public function delete(string $id) : void |
62
|
|
|
{ |
63
|
|
|
$this->client->delete(self::ENDPOINT . '/' . $id); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return \tbclla\Revolut\Builders\CounterpartyBuilder |
68
|
|
|
*/ |
69
|
|
|
public function build() |
70
|
|
|
{ |
71
|
|
|
return new CounterpartyBuilder($this); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|