1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ipag\Sdk\Model; |
4
|
|
|
|
5
|
|
|
use Ipag\Sdk\Model\Schema\Schema; |
6
|
|
|
use Ipag\Sdk\Model\Schema\SchemaBuilder; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Voucher Class |
10
|
|
|
* |
11
|
|
|
* Classe responsável por representar o recurso Voucher. |
12
|
|
|
*/ |
13
|
|
|
class Voucher extends Model |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @param array $data |
18
|
|
|
* array de dados do Voucher. |
19
|
|
|
* |
20
|
|
|
* + [`'order'`] array (opcional) dos dados do Order. |
21
|
|
|
* +   [`'order_id'`] string. |
22
|
|
|
* +   [`'amount'`] float. |
23
|
|
|
* +   [`'created_at'`] string. |
24
|
|
|
* +   [`'callback_url'`] string. |
25
|
|
|
* |
26
|
|
|
* + [`'seller'`] array (opcional) dos dados do Seller. |
27
|
|
|
* +   [`'cpf_cnpj'`] string (opcional). |
28
|
|
|
* |
29
|
|
|
* + [`'customer'`] array (opcional) dos dados do Customer. |
30
|
|
|
* +   [`'name'`] string. |
31
|
|
|
* +   [`'email'`] string (opcional). |
32
|
|
|
* +   [`'phone'`] string (opcional). |
33
|
|
|
* +   [`'cpf_cnpj'`] string (opcional). |
34
|
|
|
* +   [`'birthdate'`] string (opcional) {`Formato: Y-m-d`}. |
35
|
|
|
* +   [`'address'`] array (opcional) dos dados do Address. |
36
|
|
|
* +    [`'street'`] string (opcional). |
37
|
|
|
* +    [`'number'`] string (opcional). |
38
|
|
|
* +    [`'district'`] string (opcional). |
39
|
|
|
* +    [`'city'`] string (opcional). |
40
|
|
|
* +    [`'state'`] string (opcional). |
41
|
|
|
* +    [`'zipcode'`] string (opcional). |
42
|
|
|
*/ |
43
|
|
|
public function __construct(?array $data = []) |
44
|
|
|
{ |
45
|
|
|
parent::__construct($data); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function schema(SchemaBuilder $schema): Schema |
49
|
|
|
{ |
50
|
|
|
$schema->has('order', Order::class)->nullable(); |
51
|
|
|
$schema->has('seller', Seller::class)->nullable(); |
52
|
|
|
$schema->has('customer', Customer::class)->nullable(); |
53
|
|
|
|
54
|
|
|
return $schema->build(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Retorna o objeto `Order` associado ao `Voucher`. |
59
|
|
|
* |
60
|
|
|
* @return Order|null |
61
|
|
|
*/ |
62
|
|
|
public function getOrder(): ?Order |
63
|
|
|
{ |
64
|
|
|
return $this->get('order'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Seta o objeto `Order` associado ao `Voucher`. |
69
|
|
|
* |
70
|
|
|
* @param Order|null $order |
71
|
|
|
* @return self |
72
|
|
|
*/ |
73
|
|
|
public function setOrder(?Order $order = null): self |
74
|
|
|
{ |
75
|
|
|
$this->set('order', $order); |
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Retorna o objeto `Seller` associado ao `Voucher`. |
81
|
|
|
* |
82
|
|
|
* @return Seller|null |
83
|
|
|
*/ |
84
|
|
|
public function getSeller(): ?Seller |
85
|
|
|
{ |
86
|
|
|
return $this->get('seller'); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Seta o objeto `Seller` associado ao `Voucher`. |
91
|
|
|
* |
92
|
|
|
* @param Seller|null $seller |
93
|
|
|
* @return self |
94
|
|
|
*/ |
95
|
|
|
public function setSeller(?Seller $seller = null): self |
96
|
|
|
{ |
97
|
|
|
$this->set('seller', $seller); |
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Retorna o objeto `Customer` associado ao `Voucher`. |
103
|
|
|
* |
104
|
|
|
* @return Customer|null |
105
|
|
|
*/ |
106
|
|
|
public function getCustomer(): ?Customer |
107
|
|
|
{ |
108
|
|
|
return $this->get('customer'); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Seta o objeto `Customer` associado ao `Voucher`. |
113
|
|
|
* |
114
|
|
|
* @param Customer|null $customer |
115
|
|
|
* @return self |
116
|
|
|
*/ |
117
|
|
|
public function setCustomer(?Customer $customer = null): self |
118
|
|
|
{ |
119
|
|
|
$this->set('customer', $customer); |
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
} |