1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Fenerum\API; |
6
|
|
|
|
7
|
|
|
class Recipient extends Base |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @param string $uuid |
11
|
|
|
* @return array|null |
12
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
13
|
|
|
*/ |
14
|
|
|
public function getRecipient(string $uuid): ?array |
15
|
|
|
{ |
16
|
|
|
return $this->client->get('recipients/'.$uuid.'/'); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param array $data |
21
|
|
|
* @return array|null |
22
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
23
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumValidationException |
24
|
|
|
*/ |
25
|
|
|
public function createRecipient(array $data): ?array |
26
|
|
|
{ |
27
|
|
|
$this->validate($data, [ |
28
|
|
|
'account' => 'required|string', |
29
|
|
|
'name' => 'required|string', |
30
|
|
|
'email' => 'required|email', |
31
|
|
|
'receive_invoice' => 'required|boolean', |
32
|
|
|
'receive_payment_confirmation' => 'required|boolean', |
33
|
|
|
'receive_subscription_notifications' => 'required|boolean', |
34
|
|
|
]); |
35
|
|
|
|
36
|
|
|
return $this->client->post('recipients/', $data); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param array $data |
41
|
|
|
* @param string $uuid |
42
|
|
|
* @return array|null |
43
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
44
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumValidationException |
45
|
|
|
*/ |
46
|
|
|
public function updateRecipient(array $data, string $uuid): ?array |
47
|
|
|
{ |
48
|
|
|
$this->validate($data, [ |
49
|
|
|
'account' => 'required|string', |
50
|
|
|
'name' => 'required|string', |
51
|
|
|
'email' => 'required|email', |
52
|
|
|
'receive_invoice' => 'required|boolean', |
53
|
|
|
'receive_payment_confirmation' => 'required|boolean', |
54
|
|
|
'receive_subscription_notifications' => 'required|boolean', |
55
|
|
|
]); |
56
|
|
|
|
57
|
|
|
return $this->client->put('recipients/'.$uuid.'/', $data); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param string $uuid |
62
|
|
|
* @return array|null |
63
|
|
|
* @throws \Fenerum\API\Exceptions\FenerumApiException |
64
|
|
|
*/ |
65
|
|
|
public function deleteRecipient(string $uuid): ?array |
66
|
|
|
{ |
67
|
|
|
return $this->client->delete('recipients/'.$uuid.'/'); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|