|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace tbclla\Revolut\Resources; |
|
4
|
|
|
|
|
5
|
|
|
use tbclla\Revolut\Builders\PaymentDraftBuilder; |
|
6
|
|
|
use tbclla\Revolut\Interfaces\Buildable; |
|
7
|
|
|
|
|
8
|
|
|
class PaymentDraft extends Resource implements Buildable |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* The enpoint for payment draft requests |
|
12
|
|
|
* |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
const ENDPOINT = '/payment-drafts'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#payment-drafts-create-a-payment-draft 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 payment drafts |
|
27
|
|
|
* |
|
28
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts 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(self::ENDPOINT); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Get a payment draft by its ID |
|
40
|
|
|
* |
|
41
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts-get-payment-draft-by-id Official API documentation |
|
42
|
|
|
* @param string $id The ID of the payment draft 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 payment draft by its ID |
|
54
|
|
|
* |
|
55
|
|
|
* @see https://revolut-engineering.github.io/api-docs/business-api/#get-payment-drafts-delete-payment-draft Official API documentation |
|
56
|
|
|
* @param string $id The ID of the payment draft 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\PaymentDraftBuilder |
|
68
|
|
|
*/ |
|
69
|
|
|
public function build() |
|
70
|
|
|
{ |
|
71
|
|
|
return new PaymentDraftBuilder($this); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|