1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ipag\Sdk\Endpoint; |
4
|
|
|
|
5
|
|
|
use Ipag\Sdk\Core\Endpoint; |
6
|
|
|
use Ipag\Sdk\Http\Response; |
7
|
|
|
use Ipag\Sdk\Model\Establishment; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* EstablishmentEndpoint class |
11
|
|
|
* |
12
|
|
|
* Classe responsável pelo controle dos endpoints do recurso Establishment. |
13
|
|
|
* |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
class EstablishmentEndpoint extends Endpoint |
17
|
|
|
{ |
18
|
|
|
protected string $location = '/service/resources/establishments'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Endpoint para criar um recurso `Establishment` |
22
|
|
|
* |
23
|
|
|
* @param Establishment $establishment |
24
|
|
|
* @return Response |
25
|
|
|
*/ |
26
|
|
|
public function create(Establishment $establishment): Response |
27
|
|
|
{ |
28
|
|
|
return $this->_POST($establishment->jsonSerialize()); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Endpoint para atualizar um recurso `Establishment` |
33
|
|
|
* |
34
|
|
|
* @param Establishment $establishment |
35
|
|
|
* @param string $uuid |
36
|
|
|
* @return Response |
37
|
|
|
* |
38
|
|
|
* @codeCoverageIgnore |
39
|
|
|
*/ |
40
|
|
|
public function update(Establishment $establishment, string $uuid): Response |
41
|
|
|
{ |
42
|
|
|
return $this->_PUT($establishment, ['id' => $uuid]); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Endpoint para obter um recurso `Establishment` |
47
|
|
|
* |
48
|
|
|
* @param string $uuid |
49
|
|
|
* @return Response |
50
|
|
|
* |
51
|
|
|
* @codeCoverageIgnore |
52
|
|
|
*/ |
53
|
|
|
public function get(string $uuid): Response |
54
|
|
|
{ |
55
|
|
|
return $this->_GET(['id' => $uuid]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Endpoint para listar recursos `Establishment` |
60
|
|
|
* |
61
|
|
|
* @param array|null $filters |
62
|
|
|
* @return Response |
63
|
|
|
* |
64
|
|
|
* @codeCoverageIgnore |
65
|
|
|
*/ |
66
|
|
|
public function list(?array $filters = []): Response |
67
|
|
|
{ |
68
|
|
|
return $this->_GET($filters ?? []); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Endpoint `Transaction` do recurso `Establishment`. |
73
|
|
|
* |
74
|
|
|
* @return EstablishmentTransactionEndpoint |
75
|
|
|
* |
76
|
|
|
* @codeCoverageIgnore |
77
|
|
|
*/ |
78
|
|
|
public function transaction(): EstablishmentTransactionEndpoint |
79
|
|
|
{ |
80
|
|
|
return EstablishmentTransactionEndpoint::make($this->parent, $this->parent); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Endpoint `PaymentMethods` do recurso `Establishment`. |
85
|
|
|
* |
86
|
|
|
* @return EstablishmentPaymentMethodsEndpoint |
87
|
|
|
* |
88
|
|
|
* @codeCoverageIgnore |
89
|
|
|
*/ |
90
|
|
|
public function paymentMethods(): EstablishmentPaymentMethodsEndpoint |
91
|
|
|
{ |
92
|
|
|
return EstablishmentPaymentMethodsEndpoint::make($this->parent, $this->parent); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Endpoint `Antifraud` do recurso `Establishment`. |
97
|
|
|
* |
98
|
|
|
* @return EstablishmentAntifraudEndpoint |
99
|
|
|
* |
100
|
|
|
* @codeCoverageIgnore |
101
|
|
|
*/ |
102
|
|
|
public function antifraud(): EstablishmentAntifraudEndpoint |
103
|
|
|
{ |
104
|
|
|
return EstablishmentAntifraudEndpoint::make($this->parent, $this->parent); |
105
|
|
|
} |
106
|
|
|
} |