|
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
|
|
|
* Event Class |
|
10
|
|
|
* |
|
11
|
|
|
* Classe responsável por representar o recurso Event. |
|
12
|
|
|
* |
|
13
|
|
|
*/ |
|
14
|
|
|
final class Event extends Model |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @param array $data |
|
18
|
|
|
* array de dados do Event. |
|
19
|
|
|
* |
|
20
|
|
|
* + [`'name'`] string (opcional). |
|
21
|
|
|
* + [`'date'`] string (opcional). |
|
22
|
|
|
* + [`'type'`] string (opcional). |
|
23
|
|
|
* + [`'subtype'`] string (opcional). |
|
24
|
|
|
* |
|
25
|
|
|
* + [`'venue'`] array (opcional) dos dados do Venue. |
|
26
|
|
|
* +   [`'name'`] string (opcional). |
|
27
|
|
|
* +   [`'capacity'`] int (opcional). |
|
28
|
|
|
* +   [`'address'`] string (opcional). |
|
29
|
|
|
* +   [`'city'`] string (opcional). |
|
30
|
|
|
* +   [`'state'`] string (opcional). |
|
31
|
|
|
* |
|
32
|
|
|
* + [`'tickets'`] array (opcional) dos dados do `Ticket`. |
|
33
|
|
|
* +   [`'id'`] string (opcional). |
|
34
|
|
|
* +   [`'category'`] string (opcional). |
|
35
|
|
|
* +   [`'premium'`] bool (opcional). |
|
36
|
|
|
* +   [`'section'`] string (opcional). |
|
37
|
|
|
* |
|
38
|
|
|
* +   [`'attendee'`] array (opcional) dos dados do Attendee. |
|
39
|
|
|
* +     [`'document'`] string (opcional). |
|
40
|
|
|
* +     [`'dob'`] string (opcional) {Formato: `Y-m-d`}. |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct(?array $data = []) |
|
43
|
|
|
{ |
|
44
|
|
|
parent::__construct($data); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function schema(SchemaBuilder $schema): Schema |
|
48
|
|
|
{ |
|
49
|
|
|
$schema->string('name')->nullable(); |
|
50
|
|
|
$schema->string('date')->nullable(); |
|
51
|
|
|
$schema->string('type')->nullable(); |
|
52
|
|
|
$schema->string('subtype')->nullable(); |
|
53
|
|
|
|
|
54
|
|
|
$schema->has('venue', Venue::class)->nullable(); |
|
55
|
|
|
$schema->hasMany('tickets', Ticket::class)->nullable(); |
|
56
|
|
|
|
|
57
|
|
|
return $schema->build(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Retorna o valor da propriedade `name`. |
|
62
|
|
|
* |
|
63
|
|
|
* @return string|null |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getName(): ?string |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->get('name'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Seta o valor da propriedade `name`. |
|
72
|
|
|
* |
|
73
|
|
|
* @param string|null $name |
|
74
|
|
|
* @return self |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setName(?string $name = null): self |
|
77
|
|
|
{ |
|
78
|
|
|
$this->set('name', $name); |
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Retorna o valor da propriedade `date`. |
|
84
|
|
|
* |
|
85
|
|
|
* @return string|null |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getDate(): ?string |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->get('date'); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Seta o valor da propriedade `date`. |
|
94
|
|
|
* |
|
95
|
|
|
* @param string|null $date |
|
96
|
|
|
* @return self |
|
97
|
|
|
*/ |
|
98
|
|
|
public function setDate(?string $date = null): self |
|
99
|
|
|
{ |
|
100
|
|
|
$this->set('date', $date); |
|
101
|
|
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Retorna o valor da propriedade `type`. |
|
106
|
|
|
* |
|
107
|
|
|
* @return string|null |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getType(): ?string |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->get('type'); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Seta o valor da propriedade `type`. |
|
116
|
|
|
* |
|
117
|
|
|
* @param string|null $type |
|
118
|
|
|
* @return self |
|
119
|
|
|
*/ |
|
120
|
|
|
public function setType(?string $type = null): self |
|
121
|
|
|
{ |
|
122
|
|
|
$this->set('type', $type); |
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Retorna o valor da propriedade `subtype`. |
|
128
|
|
|
* |
|
129
|
|
|
* @return string|null |
|
130
|
|
|
*/ |
|
131
|
|
|
public function getSubtype(): ?string |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->get('subtype'); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Seta o valor da propriedade `subtype`. |
|
138
|
|
|
* |
|
139
|
|
|
* @param string|null $subtype |
|
140
|
|
|
* @return self |
|
141
|
|
|
*/ |
|
142
|
|
|
public function setSubtype(?string $subtype = null): self |
|
143
|
|
|
{ |
|
144
|
|
|
$this->set('subtype', $subtype); |
|
145
|
|
|
return $this; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* Retorna o valor da propriedade `venue`. |
|
150
|
|
|
* |
|
151
|
|
|
* @return Venue|null |
|
152
|
|
|
*/ |
|
153
|
|
|
public function getVenue(): ?Venue |
|
154
|
|
|
{ |
|
155
|
|
|
return $this->get('venue'); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Seta o valor da propriedade `venue`. |
|
160
|
|
|
* |
|
161
|
|
|
* @param Venue|null $venue |
|
162
|
|
|
* @return self |
|
163
|
|
|
*/ |
|
164
|
|
|
public function setVenue(?Venue $venue = null): self |
|
165
|
|
|
{ |
|
166
|
|
|
$this->set('venue', $venue); |
|
167
|
|
|
return $this; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* Retorna o array `tickets` referente ao recurso `Event`. |
|
172
|
|
|
* |
|
173
|
|
|
* @return array|null |
|
174
|
|
|
*/ |
|
175
|
|
|
public function getTickets(): ?array |
|
176
|
|
|
{ |
|
177
|
|
|
return $this->get('tickets'); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Seta o array `tickets` referente ao recurso `Event`. |
|
182
|
|
|
* |
|
183
|
|
|
* @param array|null $tickets |
|
184
|
|
|
* @return self |
|
185
|
|
|
*/ |
|
186
|
|
|
public function setTickets(?array $tickets = null): self |
|
187
|
|
|
{ |
|
188
|
|
|
$this->set('tickets', $tickets); |
|
189
|
|
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* Adiciona um novo objeto `Ticket` ao recurso `Event`. |
|
194
|
|
|
* |
|
195
|
|
|
* @param Ticket $ticket |
|
196
|
|
|
* @return self |
|
197
|
|
|
*/ |
|
198
|
|
|
public function addTicket(Ticket $ticket): self |
|
199
|
|
|
{ |
|
200
|
|
|
$this->set( |
|
201
|
|
|
'tickets', |
|
202
|
|
|
[ |
|
203
|
|
|
...$this->get('tickets'), |
|
204
|
|
|
$ticket |
|
205
|
|
|
] |
|
206
|
|
|
); |
|
207
|
|
|
|
|
208
|
|
|
return $this; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
} |